I’m an Actionscript / C# programmer and a beginner with Unity. I’m trying to design a classic 2D platform game together with a designer, using planes with Unity 3. I’ve got the very basics working but I’d like some help and advice with a couple of points. For instance…
The integrated physics are a great advantage but thre are some small issues I’d like to correct. If I walk to the edge of a platform, I’d like the caracter to suddenly drop when he goes too far, and not slowly start sliding down. In the same way I’d like the player to either land or totally miss a platform when he jumps. Could this be done maybe using the ContactPoint?
Is there a way I could make a more precise collider instead of just a box collider even though its for a plane?
I’ve read a book on unity and followed several tutorials and one single 2D platform tutorial, but I still would like some more advanced resources. So if you know anything (online tutorials, books,… etc) that could help me with this game in particular I’d be very greatful if you can point them out.
I do something similar to this. On platform collision I do a raycast towards the contact point and use the results to decide if the player is going to land properly or set the players ridigbody to kinematic and flag it for a “hang” transition if they’re going to miss. I do the same on the edge of platforms the player moves towards for the “teeter” status.
How do you define precise?
Or what exactly are you finding inprecise about using a box collider?
I use a capsule collider and a rigidbody in my game, so far it’s working well. Haven’t had too many issues thus far. For really solid character controls you can’t rely on the physics system alone, it’s a good base but a tad too general for character control. For the player character I pretty much take total control of rigidbody.velocity and adjust it directly. For the most part collision detection is fantastic but a rigidbody doesn’t behave like a flexible human body so I find myself hooking into the collision detection and hard-coding custom “responses” to collisions a lot that make it seem more “human”.
My best advice is to experiment, there’s no right or wrong way to skin this cat. Learn to love the Unity manual and scripting reference. Oh and read through Scott Rogers (Mr Boss’) Platformer Primer, he’s a fantastic designer and it’s a fab little resource with lots of invaluable insights you probably won’t find in any book:
Thanks cameron that was very helpful. I managed to tweak the behaviour of my character when he walks off an edge. I’m not sure how to calculate where he is going to land before he touches the ground but I’m looking into it.