Hi everyone! I'm working on a very simple game to get myself familiar with Unity iPhone and I've got almost all the major parts working great but I was wondering if anyone can help me out with one little problem. I've got a player character that's setup to move forward, backward, and sideways by tilting the iPhone and he jumps the moment he's on the ground, over and over. This is actually what I want for the gameplay. My only trick now is getting my player character to correctly move through platforms so he can jump on top of them but have no trouble passing right through them from underneath. I'm using flat polygon meshes for collision so he's able to make it through but he seems to collide with them from the sides and their interiors making movement a bit clunky when he's jumping up through groups of small platforms. Here's my code for the character controller, kind of a stripped down hack job of the Player Relative Control script included with Unity iPhone:
Thanks looking and any ideas someone might have! I am LOVING this Unity stuff SO MUCH! Seriously best development community I have EVER SEEN!
Oh and any ideas on simplifying my code for tilting to move and adjusting the starting angle the iPhone is held at would be AMAZING but no worries on that, I'll find ways eventually. XD
asked Jul 13 '10 at 05:23 AM
I would probably go for a simple raycast from the players feet level downwards, but only when the players velocity is downwards. That way you should get accurate collision detection with the platforms only when you can 'land' on them and thus allow the player to jump up 'through' them.
You may need to use 2 ray casts one for each edge/foot of the player, so they can land half on a platform.
Alternatively you add a second collider to the player and attach it to around their feet level. Then use that to check for collisions with platforms, but only if the player velocity is downwards. If the velocity is upwards, ignore any collisions. Only issue here is if the player feet collider is 'within' the platform collider as the velocity changes, you might find they get stuck in the platform.
answered Jul 13 '10 at 06:06 AM