I Have nothing in my scene except my player with one line of code that concerns the rigidbody of the player.
The line is:
RB.velocity += new Vector2(force/ RB.mass, 0);
As one would expect, this adds the force I want to my player. This, however, does not work, because the velocity of my rigidbody2D gets flipped around. In the following, I have graphed it out in an attached Excel graph:
As you can see, the velocity inverts it self each (fixed update) tick, which result in a damped vibration-like teleport instead of a smooth force.
Has anyone an idea why this is happening?
PS: the same line of code but for the vertical direction is working perfectly fine without any problems. Only the horizontal direction is causing me problems.
There’s no way to give you an answer because you have only shown a pretty graph and a simple line of code but we don’t see the values being used in the code nor do we understand what’s happening to that Rigidbody2D in the simulation i.e. does it have contacts, are forces being applied etc.
It’s just not clear if this is a math question or if this is a “what is the simulation doing” question or a combination of both.
well, thats what I did it for. I had tested whether doing it more “manually” would change things for me and forgot to change it back. Anyways, I just upgraded my project to a newer version (2022) and now it’s working just fine, so I will close this thread.