I’m using AddForce to have my object travel to my mouse input. However, I want the direction of force to always be in the direction of the mouse input. At the moment, when I try to change the direction of the object, I’m getting a lot of ‘over-shooting’ or ‘drag effect’.
I would like to know how I could approach this problem
According to the laws of physics, changing direction is changing speed, so doing what you said shouldn’t be possible.
That said, if you want your object to move at a constant rate, maybe you don’t want to use the physics system at all, but rather make it kinematic and move it solely through your script.
I will just say that what you want seems like it’s negating much of the usefulness of actually using the physics engine so you may want to look into simpler (and more easily controlled) methods of moving objects. Also, you’re using smooth-lerping to slowly change your rotation, which seems counterproductive if your goal is to have immediate and absolute control over the vector of your object.
I actually want to keep the lerping (so yes there is a slight delay but not as strong as the addforce effect). I think I will scrap the physics engine and just adjust the players velocity directly instead, because that actually achieves the effect I want.
You want to maintain a constant speed regardless of the direction? This is actually relatively simple. Pseudo code as follows.
// Set these variables elsewhere
public Vector3 targetDirection;
public float targetSpeed;
void FixedUpdate (){
// Cacheing your RigidBody is still a good idea
GetComponent<RigidBody>().velocity = targetDirection.normalised * targetSpeed;
}
Actually, speed is ignorant of direction. Speed is just the rate at which an object covers a distance. What you are thinking of is velocity, which is both speed and direction. Therefore, changing direction would not affect the speed of the object, but rather the velocity of the object.
Edit: I see this was already addressed later in the thread… my bad