At the start i just press w to go forward because i looked diagonal, character doesnt go straight even when i look straight forward.
Later i try to go diagonal by pressing w and a keys at the same time you can see that from the character’s face but this character just goes straight. I think character is incluenced under old forces and i couldn’t figure out how to eleminate this behiavour.
In the video above, release movement controls once you turn the camera and your character starts sliding. See what happens. Then push forward, then see what happens.
The problem is that you never alter existing velocity, just keep adding. Velocity is only reset when your control movement vector is zero.
However, in this scenario if you push forward, then without releasing controls turn, this happens:
You keep adding more and more velocity, and velocity is a vector. Because results keep accumulating, the character keeps moving in the old direction until you cancel it. It is like flying in space under newtonian mechanics.
To alter the behavior, try this:
Read current velocity of character. (where the character is going)
Read desired velocity (where the character should be going)
Alter velocity using acceleration (limited by character stats), until the character is going in desired direction at desired speed.
Also note that currently pressing forward will push your character into ground, because camera is looking down. You might want to project movement vectors onto ground plane, then normalize them.
Also, in your calculation you negate movement vector twice, which is not necessary.
Thanks your suggestions fixed the issue!! By changing the code from adding force to changing velocity of the character. Also I used Vector3.ProjectOnPlane to fix the movementVector. There is still some sliding very small but it is about the mass and friction of the character and it can be ignored