stoping objects oncollision exit

how can i an exit script to this script so instead of stoping objects completely on exit it will like slowly come to a stop rather than instantly? public bool useFixedDirection;
public Vector3 pullDirection;
public float timescale = 1;
public float pullSpeed;
public float radius;

 private SphereCollider _col;
 private Vector3 _enterDirection;

 private void Start()
 {
     _col = GetComponent<SphereCollider>();
 }

 private void Update()
 {
     _col.radius = radius;
     Time.timeScale = timescale;
 }

 private void OnTriggerEnter(Collider other)
 {
     _enterDirection = (transform.position - other.transform.position).normalized;
 }

 private void OnTriggerStay(Collider other)
 {
     float _dist = Vector3.Distance(other.transform.position, transform.position);
     float _ratio = _dist / radius;
     if (useFixedDirection)
         other.attachedRigidbody.AddForce(pullDirection * pullSpeed * _ratio);
     else
         other.attachedRigidbody.AddForce(_enterDirection * pullSpeed * _ratio);
 }

 private void OnTriggerExit(Collider other)
 {
     other.attachedRigidbody.velocity = Vector3.zero;
 }

}

@Kilsnus

Simply change the line in OnTriggerExit to

		other.attachedRigidbody.drag = 1;

This will increase the drag once it exit the tornado causing it to slow down. And if you have gravity turned on, it will be pulled down also.


As you get more familiar with the codes, I believe you can further improve the simulation, like gradually increasing drag to create the effect you want, etc. Just play around and do experiments with the codes to create a believable simulation.

Hi i have written a blog on -How colliders work in unity and how to interact with colliders using script. Pls visit and show some love.
Thank you in advance…
link text