Total Noob humbly needs help!

Hi all, I’m trying to freeze my player (doesn’t jump, only moves) from moving left or right when it enters the Box Collider on top of the end platform. I got it set up on top of the end platform area, the OnTriggerEnter code is set up, and the “Is Trigger” box is checked. How do I use this code?

GetComponent().RigidbodyConstraints.FreezePositionX;

I tried using it in my code right after my stage complete text but it won’t work, what am I doing wrong?

It took me a bit of playing around, but I discovered how to freeze a particular constraint on a rigidbody.

GetComponent().constraints = RigidbodyConstraints.(Whatever you want to freeze); works but it will maintain the rest of the other constraints to be free.

So if you wish to do multiple constraints, you have to use the | symbol. So for a single constraint in your case, GetComponent().constraints = RigidbodyConstraints.FreezePositionX; works.

If for multiple, then for example freezing both X and Y but keeping Z and all rotation free, would be GetComponent().constraints = RigidbodyConstraints.FreezePositionY|RigidbodyConstraints.FreezePositionX;

Basis for Rigidbody Constraints:

Different types you can access:

1 Like

Oh thank you so much, this helps me out a lot! So I was supposed to put:

GetComponent().constraints = RigidbodyConstraints.FreezePositionX;

and not:

GetComponent().RigidbodyConstraints.FreezePositionX;

I’m a total noob to this and still learning but I like the game making process.

Again, thank you so much! I bow to you sensei!! :slight_smile:

You’re welcome. Quite new at this myself, so it is learning process for me as well.

1 Like

That’s called bitwise operator. You can read more about it here :

https://msdn.microsoft.com/en-us/library/kxszd0kx(v=VS.80).aspx