Hi everyone, I’m working on a 2D sidescroller using the new 2D features from 4.3.
To start off, I created a player movement script that uses the 4.3 workflow demo as a base.
I’ve copied their jump scripting to a tee, but for some reason, my character’s jump works unusually. Instead of rising gradually, he shoots up, and then descends normally (as seen below). The rigidbody2D settings are exactly the same as well.
The problem is that you add a huge force to it, which blows him up in the air seemingly teleporting up instantly.
I believe you could fix this by applying a smaller value over time, so it would transition a bit more nicely.
So basically add a smaller force to it and don’t set the jump to false instantly, instead make a timer and set it to false only a second later.
You can do this two ways co-routine or just add a Time variable and when jump is true add deltaTime to it. When this value gets higher then the threshold and jump is true then set jump to false and zero down the time variable.
Ok, I initially closed this question because I thought the answer had nothing to do with the script, which is true, but I’ve discovered the source of the problem and I’d like to share it for anyone else who’s battling with this problem. when I turned the “Apply Root Motion” option off on the animator component my character was able to move smoothly and the problem disappeared. I’m not entirely sure why this was a problem but I think it may have something to do with the fact that the demo player character was made of multiple parts which moved separately as opposed to the single sprite animation which I used. in any case, turn it off and the problem should be resolved
Just came across this problem myself, so just incase anyone else comes across the same problem:
in my case the problem was that i was resetting the Y velocity in my movement controls
RB.velocity = new Vector3(Input.GetAxis(“Horizontal”), 0, Input.GetAxis(“Vertical”) ;
so the upward velocity is getting zero’d in the next frame and the character starts falling (the characters downward velocity is also zero’d each frame, hence why he falls at a constant rate, rather than accelerating like normal)
Fix: RB.velocity = new Vector3(Input.GetAxis(“Horizontal”) , RB.velocity.y, Input.GetAxis(“Vertical”));
My assumption is that in the case above some other script that also acts on the character is doing something similar (resetting the velocity every frame)