- Home /
 
              This question was 
             closed May 09, 2019 at 11:01 AM by 
             adovehv for the following reason: 
             
 
            The question is answered, right answer was accepted
 
               Question by 
               adovehv · May 06, 2019 at 04:40 PM · 
                rigidbody2dfreezeconstraintsconstraint  
              
 
              Freeze gameobject with a collision
Hi! I have a enemy that launches a projectile, what I want to do is this, when the projectile collide with the player or the weapon, stay still, but I have tried with "RigidbodyConstraints2D" but not work. How could I do it? Thank so much! :)


               Comment
              
 
               
              Answer by Magso · May 06, 2019 at 05:14 PM
You're using a kinematic body so it's ignored by the physics engine. You need to stop rb2d.MovePosition by using a boolean that equals true when the trigger happens.
 bool projectileTriggered;
 
 void FixedUpdate ()
 {
     if(!projectileTriggered)
     {
         //MovePosition...
     }
 }
 
 void OnTriggerEnter()
 {
     projectileTriggered = true;
     //other code
 }
 
              Follow this Question
Related Questions
Help my rigidbody2d is freezing 0 Answers
Freezing Rigidbody Rotation 1 Answer
iTween moveby constrained by rigidbody constraints in Unity 5 2 Answers
Rgidbody 2d keeps freezing 0 Answers
Rigidbody2D freezes 0 Answers