• Unity3D - Discussion
    5,004 replies, posted
Are there any good examples/template/tutorials for an Amnesia style first person puzzle?
Just a quick question about Physics2D.OverlapCircleAll. Basically I the radius I set to be in OverlapCircleAll is not the same with what I set my CircleCollider2D to be. I cannot say I understand it fully so probably that's why. If I set the radius to 5 in the code it's too small if it's 10 it's outside the CircleCollider but 9 seems fine, why is that? [code] Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, 9f); [/code] [img]https://dl.dropboxusercontent.com/u/16648713/ShareX/2015-03/2015-03-05_21-17-32.png[/img] [img]https://dl.dropboxusercontent.com/u/16648713/ShareX/2015-03/2015-03-05_21-16-04.png[/img]
I have a camera that is a child of an empty object I'm using as a pivot point. The camera is rotated down at the pivot point and I'm using transform.forward to move the camera along its z-axis to zoom in on the pivot point. I've ran into an issue though. When I rotate the pivot point, transform.forward breaks and no longer moves the direction the camera is facing. It moves left and right and backwards. What's the best way to zoom in on an object without changing the FOV of the camera? The transform.forward with a LERP doesn't seem to be working.
I'm having some trouble unloading a sprite and freeing the memory. I have a sprite that's imported using Resources.Load(), and as expected, the memory increases. But the problem is, I can't seem to figure out how to free the memory. I know I need to use Resources.UnloadUnusedAssets(), but even when I first remove all the references to the sprite, the memory doesn't go back down. Here's my code right now: Loading the sprite (works fine): [CODE] map = Resources.Load <Sprite> ("Map7"); spRend = this.GetComponent<SpriteRenderer>(); spRend.sprite = map; [/CODE] Unloading the sprite (memory isn't freed): [CODE] spRend.sprite = null; map = null; Resources.UnloadUnusedAssets(); [/CODE]
[QUOTE=Cow Muffins;47265323]I have a camera that is a child of an empty object I'm using as a pivot point. The camera is rotated down at the pivot point and I'm using transform.forward to move the camera along its z-axis to zoom in on the pivot point. I've ran into an issue though. When I rotate the pivot point, transform.forward breaks and no longer moves the direction the camera is facing. It moves left and right and backwards. What's the best way to zoom in on an object without changing the FOV of the camera? The transform.forward with a LERP doesn't seem to be working.[/QUOTE] Isn't zooming changing the FOV? How else would you zoom?
[QUOTE=Cow Muffins;47265323]I have a camera that is a child of an empty object I'm using as a pivot point. The camera is rotated down at the pivot point and I'm using transform.forward to move the camera along its z-axis to zoom in on the pivot point. I've ran into an issue though. When I rotate the pivot point, transform.forward breaks and no longer moves the direction the camera is facing. It moves left and right and backwards. What's the best way to zoom in on an object without changing the FOV of the camera? The transform.forward with a LERP doesn't seem to be working.[/QUOTE] Are you setting position or local position? If you're setting local position, you shouldn't be using transform.forwards (since that's in world space, not local space), and instead use Vector3.forward
[QUOTE=Pelf;47265961]Isn't zooming changing the FOV? How else would you zoom?[/QUOTE] Move the position of the camera to be closer to the object. [QUOTE=KillaMaaki;47266012]Are you setting position or local position? If you're setting local position, you shouldn't be using transform.forwards (since that's in world space, not local space), and instead use Vector3.forward[/QUOTE] I went to go try this and for some reason the axis on my camera is aligned to the world instead of itself. No matter how I rotate the camera, the axis stays pointed in the same direction... Edit: There's a button that much have gotten toggled off that lets you change the rotation gizmo to local or global. Nevermind! Vector3.forward does move the camera forward in a consistent direction, but it doesn't match the X axis rotation of the camera.
I really do not understand Unity's rotation system yet and its making this pretty hard. I want to rotate the player with 2 keys and accelerate with 2 others but I cannot seem to figure out how to make my player move towards the direction they are facing. I could do it in Lua but just can't figure out how to do that in C# [code] void Update () { Vector3 rotation = transform.rotation.eulerAngles; if (Input.GetKey("w")) { velocity = speed * Time.deltaTime; } if (Input.GetKey("s")) { velocity = -speed * Time.deltaTime; } if (Input.GetKey("a")) { rotation.z = rotation.z + 5; transform.rotation = Quaternion.Euler(rotation); } if (Input.GetKey("d")) { rotation.z = rotation.z - 5; transform.rotation = Quaternion.Euler(rotation); } float x = transform.position.x; float y = transform.position.y; velocity = velocity * transform.rotation.z; transform.position = new Vector3( x + velocity, y + velocity, transform.position.z ); } [/code]
So, how much has changed programming wise with the switch to a more modern version of PhysX? In other words, are all the video tutorials that feature physics and/or character movement outdated now?
[QUOTE=Rahu X;47268012]So, how much has changed programming wise with the switch to a more modern version of PhysX? In other words, are all the video tutorials that feature physics and/or character movement outdated now?[/QUOTE] Not at all, they should be perfectly compatible
How do I occlude lens flares with geometry and not colliders? [B]The problem:[/B] Geometry does not block a lens flare. If you have a lens flare and move an object in front of it, the lens flare remains visible. Visible geometry has no inherent property in the rendering engine which blocks line of sight to a flare. A lens flare can *only* be blocked with a collider. If you have a simple shape, this is fine. However, if you have a collision mesh that obscures parts of a model in such a way that lens flares placed on it that should be visible, are now inside that collision mesh, that flare will be blocked. To see that lens flare, you would need to fly the camera inside the collision mesh. [B]The old workaround:[/B] This problem is a big pet peeve of mine, so I had developed a workaround. I use a Mesh Collider on all of my visual models. This "visual hitbox" as I call them, doesn't collide with anything and is used *only* as a means to perfectly block lens flares based on mesh geometry. I have a separate model with a simple covex Mesh Collider as my "physical hitbox" and all other collision detection that lens flares can go through. [B]Why that doesn't work anymore:[/B] In Unity 5, non-convex MeshColliders can no longer be used with non-static rigidbodies. This means that now, only the convex, and highly imprecise, mesh collider will block lens flares. Lens flares that were previously visible using my old system are now occluded because the flares are inside the convex physical collision mesh. Because this is a very visual problem, here's a picture representing the problem: [img]http://i.imgur.com/XmPlq2t.jpg[/img] [url=http://imgs.xkcd.com/comics/workflow.png]I just realized that I am now [I]that[/I] guy[/url].
My apologizes if somebody already mentioned this, but UI buttons are being toggled when I click them. Is there a way to disable this, without writing a script to do it?
[QUOTE=Why485;47269775]How do I occlude lens flares with geometry and not colliders? [B]The problem:[/B] Geometry does not block a lens flare. If you have a lens flare and move an object in front of it, the lens flare remains visible. Visible geometry has no inherent property in the rendering engine which blocks line of sight to a flare. A lens flare can *only* be blocked with a collider. If you have a simple shape, this is fine. However, if you have a collision mesh that obscures parts of a model in such a way that lens flares placed on it that should be visible, are now inside that collision mesh, that flare will be blocked. To see that lens flare, you would need to fly the camera inside the collision mesh. [B]The old workaround:[/B] This problem is a big pet peeve of mine, so I had developed a workaround. I use a Mesh Collider on all of my visual models. This "visual hitbox" as I call them, doesn't collide with anything and is used *only* as a means to perfectly block lens flares based on mesh geometry. I have a separate model with a simple covex Mesh Collider as my "physical hitbox" and all other collision detection that lens flares can go through. [B]Why that doesn't work anymore:[/B] In Unity 5, non-convex MeshColliders can no longer be used with non-static rigidbodies. This means that now, only the convex, and highly imprecise, mesh collider will block lens flares. Lens flares that were previously visible using my old system are now occluded because the flares are inside the convex physical collision mesh. Because this is a very visual problem, here's a picture representing the problem: [img]http://i.imgur.com/XmPlq2t.jpg[/img] [url=http://imgs.xkcd.com/comics/workflow.png]I just realized that I am now [I]that[/I] guy[/url].[/QUOTE] Well I'd make my own lenseflare as a shader, draw blocking geometry on a rendertarget and use that rendertarget to tell the state of the lensflare.
[QUOTE=Elec;47269932]Well I'd make my own lenseflare as a shader, draw blocking geometry on a rendertarget and use that rendertarget to tell the state of the lensflare.[/QUOTE] Any tips on what I should read or look up? I've never done anything like that before so I don't know where to start.
[QUOTE=Why485;47270416]Any tips on what I should read or look up? I've never done anything like that before so I don't know where to start.[/QUOTE] Read lots and lots about shaders (first stop would be Unity tutorials on shaders), because that stuff looks simple but it isn't.
I was wondering if I could get some advice on physics I'm doing a sidescroller that's got a fair few physics-based puzzles. I'm taking an old flash game I was working on and remaking/expanding on it in Unity. I'm not sure whether I should use Unity's physics engine with mass and gravity, moving things around with addForce, etc, or whether I should do it the old fashioned way and write functions that manually shift the character around based on input. What do you reckon is the best solution here, given that I want to expand the character movement and world interaction later on for a variety of physics puzzles (wind, magnetism, etc)
[QUOTE=Why485;47270416]Any tips on what I should read or look up? I've never done anything like that before so I don't know where to start.[/QUOTE] Thinking about it, [url]http://docs.unity3d.com/Manual/SL-CameraDepthTexture.html[/url] that'd be a good rendertarget for you to use. Grab a tutorial to make a lenseflare that looks how you want them to look like, then change it's opacity (or however you want it to fade) based on how many pixels near the flare are before it. Use world to screen or something else to find out where the flare is on the depthtexture, or make your lenseflares shaded sprites and use their fragment shader (that's probably easier and faster than drawing a shaded quad over your screen and doing world to screen for every single lenseflare). The fragment shader supplies you with the position on screen. And like Fourier said, shaders are awful when you never worked with them, and every framework always has it's own twists.
How long/difficult is it to update a project to Unity 5? Do I have to redo all of my materials? Will my sound settings get messed up cause of the new audio stuff they added? I don't really want to have to sink too much into moving my game to Unity 5, especially because I don't really need any of the new features yet.
Most of it is automatic, I've had a few old projects I've upgraded and I didn't have to fix anything.
I've been trying to make a script that revolves around picking up items and placing them to the invetory / player's hand, but I'm having problems with raycasting. There are several items that can be picked up by pressing E, such as swords, but the raycast doesn't register the smaller collision boxes at all. When I made the ray visible, it turned out that it actually goes through the object and isn't hitting it at all. Any idea what's wrong with the script? EDIT: Here's the code that I use [CODE] var detectedObj : GameObject; var showInfo : boolean = false; function Start () { } function Update () { var fwd = transform.TransformDirection(Vector3.forward); var hit : RaycastHit; if(Physics.Raycast(transform.position, fwd,hit)) { if(hit.distance <= 5.0 && hit.collider.gameObject.tag == "Item") { showInfo = true; if(Input.GetKeyDown("e")) { Destroy(detectedObj); } } else { showInfo = false; } } } function OnGUI() { if(showInfo == true) { GUI.Box(Rect(Screen.width/2-100,Screen.height/2-100,150,30) "Press E to pick-up"); } } [/CODE]
[QUOTE=Asgard;47268819]Not at all, they should be perfectly compatible[/QUOTE] Ah, nice to know. I could've sworn they said some of the references/objects changed names, or some devs who transitioned from Unity 4 to 5 did. If there's little difference though, that's great.
Is anyone else experiencing severe performance issues after switching to Unity 5? Previously, my game was running with smooth 1000-1100 FPS, but just loading an [B]empty scene[/B] in Unity 5 results in crappy 250-300 fps.
I tried upgrading to Unity 5 but Physics2D.BoxCast isn't returning the same results as it did in Unity 4, which completely broke all my movement mechanics :(
[QUOTE=Rahu X;47273171]Ah, nice to know. I could've sworn they said some of the references/objects changed names, or some devs who transitioned from Unity 4 to 5 did. If there's little difference though, that's great.[/QUOTE] I think the only serious API change is they removed the quick component getters, so you can't do .rigidbody or .renderer anymore, the only one left is .transform
The window for Unity 5 that comes up when you first launch it to select license and log in and shit, it lags like a bitch. Did anyone else get this? [editline]edit[/editline] I think it's only that window thing, so whatever.
[QUOTE=Pelf;47275321]The window for Unity 5 that comes up when you first launch it to select license and log in and shit, it lags like a bitch. Did anyone else get this?[/QUOTE] Yeah, I did.
[QUOTE=Pelf;47275321]The window for Unity 5 that comes up when you first launch it to select license and log in and shit, it lags like a bitch. Did anyone else get this? [editline]edit[/editline] I think it's only that window thing, so whatever.[/QUOTE] It's just that window also I though it would've been fixed by now. When I first came out it was like this and wasn't expecting to be like this by now.
It's taking forever to compile scripts. Did it take forever for anyone else? I don't have that many scripts [editline]edit[/editline] oh, the popup didn't pop up in front of my other windows [IMG]https://dl.dropboxusercontent.com/u/13781308/ShareX/2015-03/2015-03-07_10-34-15.png[/IMG]
It didn't took that long to be honest, if I would have to guess I think it was like 2 min max. The total of scripts in my project = 32 and size of them = 93Kb.
[QUOTE=BoowmanTech;47275636]It didn't took that long to be honest, if I would have to guess I think it was like 2 min max. The total of scripts in my project = 32 and size of them = 93Kb.[/QUOTE] It had that popup and was waiting for me to click an option but I didn't see it because it didn't pop up over the rest of my windows. :v: also, what is this Gfx.WaitForPresent? I don't have vsync enabled so ... [t]https://dl.dropboxusercontent.com/u/13781308/ShareX/2015-03/2015-03-07_11-53-17.png[/t] [editline]7th March 2015[/editline] And for some reason my audio stopped working :/ [editline]7th March 2015[/editline] well idk why my audio isn't working. I've found a way to reproduce a fix but I don't know what could possibly be causing it to not work, so I guess I'll downgrade back to 4.6 for now.
Sorry, you need to Log In to post a reply to this thread.