How to change Force direction immediately?
Hi, I am trying to add a force on rigidBody by using a vector I am getting from the user's mouse position: up will change the vector to be:
vector+=Vector3.up * MOVEMENT_SPEED;
And the same thing with left,right,down,forward and backward.
The problem is that there is a small delay every time I change the position. For example, if I go up and then want to go down,after moving the mouse down it will first go up for a bit and only then down.
I am using:
void FixedUpdate()
{
rb.AddForce(K * vector);//K=Const
}
Is there a way to change the force direction immediately when I change the vector's position?
Answer by karl_jones · Jan 26, 2017 at 11:56 AM
Try setting the velocity directly https://docs.unity3d.com/ScriptReference/Rigidbody-velocity.html
Literally the first thing the docs say is: "In most cases you should not modify the velocity directly, as this can result in unrealistic behaviour."
Perhaps the docs have changed in 2 years time...
Your answer
Follow this Question
Related Questions
How do you fix a Rigidbody stopping quickly after the addforce stops being called? 1 Answer
Rigid body robot animation 0 Answers
How can I move an object in the direction another object is facing. 1 Answer
Bullet shooting not working 0 Answers
C# keep previous velocity while jumping, previous solutions not working 0 Answers