how disable/enable rigidbody and box collider
I am trying to make an object, that when told starts falling, and after a designated length of time respawns where it was before, but for some reason, my rigidbody and collider are not re-enabling, here is my code:
public float respawnDelay; public float WaitTime;
 public GameObject ground;
 public Rigidbody2D rb;
 public Collider2D goingThroughObjects;
 private Vector3 whereToTeleport;
 // Use this for initialization
 void Start ()
 {
     rb = GetComponent<Rigidbody2D>();
     goingThroughObjects = GetComponent<Collider2D>();
     rb.isKinematic = true;
     goingThroughObjects.enabled = true;
 }
 
 // Update is called once per frame
 void Update ()
 {
     
 }
 void OnTriggerEnter2D(Collider2D other)
 {
     if(other.tag == "HeadStomp")
     {
         StartCoroutine("TouchedBreakableObjectCo");
     }
 }
 public IEnumerator TouchedBreakableObjectCo()
 {
     whereToTeleport = ground.transform.position;
     yield return new WaitForSeconds(WaitTime);
     rb.isKinematic = false;
     yield return new WaitForSeconds(0.2f);
     goingThroughObjects.enabled = false;
     yield return new WaitForSeconds(respawnDelay);
     rb.isKinematic = true;
     goingThroughObjects.enabled = true;
     ground.transform.position = whereToTeleport;
 }
 
               PLEASE HELP
Answer by Cherno · Aug 25, 2017 at 06:14 PM
You set the RB to IsKinematic = true in Start(), but you use OnTriggerEnter2D() to try and register collisions, which is not possible with a non-kinematic RB.
Your answer
 
             Follow this Question
Related Questions
Is there a way to enable/disable a rigidbody? 1 Answer
How to Make A Character Stop At Wall? 0 Answers
Hello evryone, I need some help with basic thing. 0 Answers
Detecting collisions on an invisible grid 0 Answers
Unity 5: AddForce Increases power when already being pushed towards a collider. How to make stop? 1 Answer