Hello guys, I am new to unity.
I just want to know how can I jump from one platform to the middle of the next platform smoothly while doing a rotation. I tried using transform.Translate and rigidbody.Addforce. Both of them feels jerky and can not jump correctly to the next position.
If you’re new to Unity, I think you’re being a little ambitious. Let me explain why.
transform.Translate moves in a straight line. However, you probably want an arc to go from the current tile to the next. That means following a curved path, which is not a beginner task. This is made worse if you want to rotate because you need to understand the difference between local space and world space. Not difficult but it adds another level of complexity.
RigidBody.AddForce could, in theory, give you the right results, assuming you applied a force that was both vertical and lateral. However, you want it to be smoother and to land in the centre. Believe me when I say that mathematicians worked for centuries on ballistics calculations and, although the formulae are nailed down now, you’ve got to consider residual lateral velocity when you land on the next tile. Very tricky.
The best solution is to figure out the exact curved path and follow that over a fixed period of time. These types of paths are called Splines and, although Unity is now introducing these in the latest version of the Editor, you may have to go to the Asset Store to find one that works for you. That means installing a package, learning how it works and coding it up.
Is there something that you can do? You could forget rotation for now (there are some potential complexities with Quaternions, which is how Unity stores Rotations internally. Perhaps move from the current position in a straight line to a point above the centre of the next tile and then another straight line down to its centre. You’ll need to use a function called “lerp” and you can find out more about it at John French’s blog here
Moving in 2 straight lines may not look natural but it’s a lot easier than calculating curves and following them at this stage of your journey. Good luck!