Can’t reset constraints on script

Updated on May 22, 2018 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on May 22, 2018

So, I’ve been trying to add a few mechanics to the “How to make a game” course. I made the cube able to jump, and so far it works well, but everytime it fell, it would rotate a little. So I locked constraints and went into the code to release them again whenever the cube collided with something (so it stops rotating when it falls but still rotates when it hits an obstacle, so it looks a little cooler).

Problem is, i can’t seem to do it? Unity isn’t returning any errors, and the Debug Log is working fine. When it gets to the constraints line, it doesn’t reset the constraints at all, in fact, it doesn’t seem to be doing anything.

using UnityEngine;
public class PlayerCollision : MonoBehaviour {
public Rigidbody rb;
void OnCollisionEnter()
{ 
rb.constraints = RigidbodyConstraints.None;
Debug.Log("We hit something");
}
}

This is what I got for now. Am I missing something?

  • Liked by
Reply
0 on May 22, 2018

I found the problem and it has been fixed. Would an admin lock the thread or do I have to delete it somehow?

  • Liked by
Reply
Cancel