- Home /
Disable First Person Controller upon death.
Hello all. I am having a problem disabling the character controller upon death. I want it so when the player dies, he can no longer jump.
I have a public bool playerDead = false. When the player collides with the enemy, playerDead = true. Unfortunately the character motor script as well as the FPSInput Controller script are both in Javascript, whereas the rest of my scripts are in C#.
The javascripts are both in the standard assets assets folder, so I have no idea why I can not reference them.
Answer by AlucardJay · Apr 14, 2014 at 03:55 PM
For future readers :
var characterController : CharacterController;
characterController = GetComponent( CharacterController );
characterController.enabled = false;
var characterMotor : CharacterMotor;
characterMotor = GetComponent( CharacterMotor );
characterMotor.enabled = false;
Answer by Commander5518 · Feb 25, 2014 at 02:51 PM
if(playerDead){
canControll = false;
}
then set canControll as a public boolean variable at the top of the first person controller. Then once the player dies you can no longer use the movement from the script
Answer by Amitabha · Mar 24, 2014 at 04:29 PM
You can also try using Destroy(gameObject.GetComponent< CharacterMotor>();
Answer by John_Sherer · Apr 12, 2014 at 12:03 PM
I'm experiencing the exact same problem. The result I finally came up with was to simply set the player controller to inactive. This is a fairly simple feat to pull off, and if you don't know how to do it already, let me know and I'll explain it to you. However, the player can't move as well as jump. If you are looking to only disabling jumping, I cannot help you. Your best shot would be to learn a smidgen of Java.
I ended up making a cheap workaround that literally has me instantiating an invisible cube object above the head of my character to prevent any vertical movement hahaha.