- Home /
Animation through graphics in FPS controller, weird character controller issue, NEED help!
Hi, I'm having a problem, not sure whether it's my script, my in-scene settings, or just Unity, anyway: I am creating a 2.5D platformer in my spare time, and when I press up arrow, it jumps, which is good, I add a jump animation, still good, I try to get it to only play jump animation when isGrounded, now here's the problem: When I go to test the game, it works, I jump, it pauses it and tells me: "NullReferenceException: Object reference not set to an instance of an object MovementAnimations.Update () (at Assets/Scripts/MovementAnimations.js:12)" I then, without closing the current test, I re-drag the character controller onto the script, unpause it, and it works perfectly! But when I die or restart, I have to do the same thing. I tried redragging it when the test wasn't open at all, that doesn't work, only when the test is running! My Code: #pragma strict
var charController : CharacterController;
function Start ()
{
charController = GetComponent(CharacterController);
}
function Update () {
if (Input.GetKeyDown(KeyCode.UpArrow) && charController.isGrounded)
animation.Play("jump");
}
Please help, and if you can't please tell someone who might to check this question out, thanks. Sorry for the long read -.-
Your answer
Follow this Question
Related Questions
How do you make a characterController jump automatically when it reaches the edge of a platform? 0 Answers
How animations are executed ?? 1 Answer
Getting this character controll script working right 1 Answer
Why does my characterController code not apply gravity correctly? 0 Answers
Root motion / How to bake into pose Root Transform Position (x) 0 Answers