Making a charactercontroller immovable?
Making a charactercontroller immovable?
I've been trying to stop a charactercontroller from moving with no luck, I have a character on a ladder(so I set the velocities to Zero, and only modify it when the player presses up or down), and it works, but when another character controller pushes it, it does move, and I would like to avoid movement at all, I tried setting it to kinematic, but it starts to act very weird when I make it dynamic again(I think the constraints and joints are removed). I've been trying to figure out where does this velocities are increased with no luck, Any ideas on what can I do?. Thanks in advance
Re: Making a charactercontroller immovable?
The character constraints should not be removed, though some other non-character joints may complain about being connected to two kinematics. My guess is that the BecomeDynamic function was called without explicitly specifying an inertia tensor. This causes the inertia tensor to be recalculated. The CharacterController's body is supposed to be incapable of rotation so this causes issues. Setting the LocalInertiaTensorInverse property to all zeroes should help.I tried setting it to kinematic, but it starts to act very weird when I make it dynamic again(I think the constraints and joints are removed)
That said, I generally recommend staying within dynamic simulation over introducing discontinuities (like the character gaining effectively infinite mass on a ladder). A SingleEntityLinearMotor could be used to very robustly keep a dynamic character where you want it to be. If the ladder happens to be a dynamic object, you could use a PointOnLineJoint combined with a LinearAxisMotor to ensure proper two-way interaction.
Depending on the requirements of the simulation, this might be a case where simply teleporting the character by setting the Body.Position property would be sufficient. In isolation, this would make collision response behave strangely because the object does not have the correct velocity to match its motion, but this may not be an issue for you. A halfway point between pure teleportation and a motor would be to teleport the object but manually assign velocities which match the motion. Collision response won't be as good as with a motor while on the ladder, but it will probably be good enough.
Re: Making a charactercontroller immovable?
Thanks, it was indeed the LocalInertia that was causing the problem.