I’ve been dabbling with the 4.3 2D tools for the last week trying to get a tight 2D platformer controller working. I have used several methods to move the player around - Addforce(), velocity, and transform. I’ve found that I can get the “tightest” controls via either transform or velocity changes, but most suggestions including the documentation suggest to only manipulate the rigidbody’s movement via addforce.
I found the character controller in the 3D tools nice for achieving a 2D platformer controller, but there is not one in the 2D tools. What I am looking to achieve is instantaneous movement, and make it so the player doesn’t maintain momentum after player input is not present (I made a script that set rigidbody drag higher when there’s no input and it worked ok.)
Has anyone achieved a nice feeling player control via addforce? Should I just stick to manipulating the velocity directly?
I’ve had the most success rolling my own movement and collision code. All you really need for a platformer are rectangular bounding boxes and the ability to check if two rectangles are overlapping.
Hi, thanks for this! Can you please help me to hack the script to avoid double jump?
I’m not a coder but i think it will need a simple StartCoroutine(waitForSeconds());
somewhere in the PlayerTester.cs - maybe after the…
I haven’t used that CharacterController2D stuff myself, so I won’t be much help. But I think it contains a variable called “isGrounded” that becomes true when your character is touching the ground. To remove double jump, you would only add the jump velocity if the character is currently grounded.
I think the prime31studios solution is great but I must ask- is there a way for the player to control jump height (like mario or megaman) to make tighter platforming? Can someone please give a few guidelines on how to achieve this.
I’m looking for the same thing. Need some very tight controls for my platformer, but I have literally no idea where to start and I’ve been having a nightmare even getting Prime31’s script installed and running. I’m getting a different set of errors everytime I try it seems. Very frustrating. I’ve followed the instruction on how to install script, but for some reason I’m missing something. ANy helps at all, or links to a better tutorial than the unity one.
Indeed you shouldnt use rigidbody.velocity, unless it’s for a shadow or folowing object… you can make a transform.position controlled player, and then slave a physicial rigidbody to that player object by making it move onto him using velocity, so the physical object is 1 frame behind on where the player is, but it is controlled by transform position and has am independent physics rigidbody.