There are potentially 3 ways I've thought of which I've put in bold, that if I figure out just one of them, then my stuff will work.
I'm trying to write a script so that my character can be crushed by objects. I'm using a CharacterController for what I'll call the 'controller' and the objects crushing him are rigidbodies which I'll call the 'crusher'.
The crusher is currently using a non-kinematic rigidbody, gravity disabled and constraints set to all. I can detect being crushed perfectly fine, the problem is when my controller, say jumps, it pushes the crusher away making it fly off. How can I stop a character controller from moving the rigidbody?
I've tried setting rigidbody.velocity = Vector3.zero; every FixedUpdate. This stops the crusher flying away but you can still notice resistance.
Now if I make crusher a kinematic, it works fine, but I lose the ability to use OnCollisionEnter() and therefore the way I'm detecting the player being crushed. Is there anyway to detect a collision between a kinematic and a character controller without using OnControllerColliderHit?
Would attaching a rigidbody to my controller give me back OnCollisionEnter?
Finally I thought about using a trigger on the crusher and using OnTriggerEnter, but if I jump I just pass through the crusher. Is there anyway to prevent a collider passing through a trigger? I tried attaching a trigger to another rigidbody as a child but I still passed through it most of the time. Would separating them and position them at same place through a script work?
Cheers for advice.
-edit-
Got a video of current issue.
http://bovinelabs.com/crush/crush/
This is using a rigidbody kinematic and a separate trigger
The crusher moves on FixedUpdate() using
rigidbody.MovePosition(rigidbody.position + _direction*Speed*Time.deltaTime);
CharacterController is a heavily modified version of the FPSwalker to allow stuff like wall jumping, but I do not believe any changes would affect this.
Notice it only really does it when it's going down, and I'm moving up