Hi all,
I posted this question last week in the “Editor and general support” section but didn’t receive a response, so I thought I might try here instead. I have two static capsule colliders (without rigidbody components) placed with a small space between them. I have my character with a rigidbody capsule collider that is larger than the small gap between static colliders. Normally, the rigidbody collider will not pass through a static collider, but when two statics are placed with a gap, it seems the rigidbody collider gets pushed through one static collider by the other. What I want to happen is have the rigidbody get stopped and be unable to pass through the small gap.
The colliders are not triggers and I don’t want to substitute one big static collider for the two small statics. Also, the rigidbody collider is not moving at a very high speed. I’ve read previous threads about solving similar issues for fast moving objects, but they apparently impact performance so I’d like to avoid this since this is not a fast moving object.
Here is a screenshot where you can see the small rigidbody collider in the middle is respecting the static collider on the right, but is instead being pushed through the static collider on the left and passing through the barrier:
Here is the code I’m using for the movement of the rigidbody collider:
Vector3 movement;
Rigidbody rb;
public float walkSpeed;
void Awake()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float h = Input.GetAxisRaw("Horizontal");
float v = Input.GetAxisRaw("Vertical");
Move(h, v);
}
void Move(float h, float v)
{
movement.Set(h, 0f, v);
movement = movement.normalized * walkSpeed * Time.deltaTime;
rb.MovePosition(transform.position + movement);
}
Thanks for the help!