I’ve got a rigid body that is pulled towards my mouse position however if I move the mouse to the other side of the screen, the time it takes the object to slow down and change position to head in the other direction is too slow and carries on moving in the wrong direction for too long before switching to the new direction.
public float pullForce = 1;
public Transform player;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
// calculate direction from target to me
Vector3 forceDirection = transform.position - player.transform.position;
// apply force on target towards me
player.rigidbody.AddForce(forceDirection.normalized * pullForce * Time.fixedDeltaTime * 10);
}
This is attached to my mouse position game object. Any ideas of how to add in a “dampener” that I can use to control the speed at which the player object reacts to a change in force?