Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

how to make collider stay constant after collision?

Discussion in 'Physics' started by ozgurdugmeci, May 19, 2015.

  1. ozgurdugmeci

    ozgurdugmeci

    Joined:
    Mar 1, 2015
    Posts:
    85
    after collision the object got hitten moves a bit far from the position i want it to stay.
    simply i used this line to prevent collider to move.
    but it didnt work as i expected.

    what eshould i do to make hitten object not to move after collision ?

    Code (JavaScript):
    1. function OnCollisionEnter2D (coll : Collision2D)
    2. {
    3.    
    4.         coll.collider.rigidbody2D.velocity = Vector3.zero;
    5. }
     
  2. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    239
    You can set isKinematic to true. It wont move after that.
     
    ozgurdugmeci likes this.
  3. RifS

    RifS

    Joined:
    Nov 27, 2013
    Posts:
    33
    Try the Sleep() function as well.
     
    ozgurdugmeci likes this.
  4. ozgurdugmeci

    ozgurdugmeci

    Joined:
    Mar 1, 2015
    Posts:
    85
    thank you guys.
    it helped.
     
  5. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    Or you could just remove the rigidbody component.