Solved it myself, solution in the edit at the top of the post.
Rigidbody 2D Freeze Position X bug?
Edit- Turns out I was freezing the x position on the same frame as oncollisionenter, so it was freezing it while it was still inside the collider, so it was unable to drop down through the collider. I just converted the oncollisionenter function into an IEnumertor to make it wait a frame before freezing it.
Hi, I'm trying to create a timed wallcling, so when my character jumps onto a wall there's a short period of time where the player can't move off the wall unless they jump. To do this I'm enabling the rigidbody X position via code.
public void setFreezeX(bool constraint)
{
if (constraint)
{
Debug.Log("FreezeX");
entityRigidbody.constraints = entityRigidbody.constraints | RigidbodyConstraints2D.FreezePositionX;
}
else
entityRigidbody.constraints = entityRigidbody.constraints & ~RigidbodyConstraints2D.FreezePositionX;
}
The problem is that when I do this, the character doesn't fall down until the time I set runs out or I use my movement script to push off the wall, for example if I'm clinging onto a wall on the left, and if I push the right arrow key the character will start falling, (though it doesn't actually move right, as intended). Otherwise if I push the left arrow key or don't push any arrow keys at all my character acts as though it's y position is frozen, despite the checkbox on the rigidbody position y not being enabled, nor is kinematic enabled, gravity scale set to 1 etc etc.
Follow this Question
Related Questions
How to ensure raycasts hit colliders inside of trigger colliders on objects that have a rigidbody? 0 Answers
Cannot get rigidbody constraint to unfreeze 1 Answer
Rigidbody local position constraints 2 Answers
Cloth constraints don't constrain *o* 1 Answer
How to freeze all constraints on rigidbody except transform.forward? 0 Answers