- Home /
How to selectively ignore CharacterCollider physics response but retain other collisions for OnControllerColliderHit() ?
Example solution
The only solution I've come up with comes as 2 parts:
split floor into another layer that the CharacterCollider interacts with and
add an extra kinematic Collider around my player that does what I currently do in OnControllerColliderHit().
Obviously this mandates another GameObject for the Collider (since the top-level one already has the CharacterCollider).
I'm hoping I've missed something (like a flag that tells CC or OCCH() some details)?
All ideas (and clarification questions) most welcome!
Full background details
Specifically, I need to (a) prevent my CharacterCollider riding up a soccer-ball while allowing it to successfully (b) dribble and (c) push things?
Player (CharacterCollider, C# inc. controls that call CC.Move() & OnControllerColliderHit() for pushing)
Model tree (which I replace from Blender when updated)
CarryZone (BoxCollider, C#, kinematic RigidBody to which Spring/ConfigurableJoint attached to dribble)
Effects GO
Shadow GO
etc
I think the following is what happens (I'm not certain)...
Intermittently (probably when the fore-SpringJoint-mounted ball (which rolls against the ground) happens to slow or the player happens to be faster), for some unfathomable reason (*1), the CharacterCollider mounts the ball. Further inexplicably (*2), the spring moves the ball forwards but not enough to be removed from beneath the player and the loop continues providing a stairway to heaven (a.k.a. a critical fall when it ceases!)
*1: I say "unfathomable" because the ball is 1m radius and the CC has stepOffset:0.3 and slopeLimit:45. Am I right thinking these would require the ball to be embedded well into the ground to pass either of these tests?
*2: I say "Further inexplicably" because even on the ground, when traveling in a straight line, the ball generally stays adequately far forward to prevent problems despite ground friction. (the problems usually come when changing direction)
Thanks again!
Answer by Arkade · May 24, 2013 at 11:31 PM
Found my own answer: Physics.IgnoreCollision()! It works on CharacterCollider!