- Home /
Question by
jmaster2012 · Feb 23, 2013 at 06:46 PM ·
javascripterroranimationsjavabce0077
BCE0077: It is not possible to invoke an expression of type 'UnityEngine.Animation'. Please help.
I am making a FPS game and I am OK at scripting. I am getting that error twice, one at line 46, and one at 55. What I am trying to do is to make it so my animations play as fast as I am running so my gun is not slow but I am running really fast. Here is my script.
var PlayerState : float;
var PlayerAnimSec : GameObject;
var PlayerMotor : CharacterMotor;
var WalkingSpeed : float = 6;
var SprintingSpeed : float = 8;
var PlayerBossControll : CharacterController;
var CharacterMag;
function Update ()
{
PlayerStateController();
PlayerAnims();
CharacterMag = PlayerBossControll.velocity.magnitude;
}
function PlayerStateController()
{
if(Input.GetAxis("Vertical") !=0 || Input.GetAxis("Horizontal") !=0)
{
if(Input.GetKey("left shift"))
{
PlayerState = 2;
}
else
{
PlayerState = 1;
}
}
else
{
PlayerState = 0;
}
}
function PlayerAnims()
{
if(PlayerState == 0)
{
PlayerAnimSec.animation.CrossFade("Idle Animation", 0.4);
}
else if(PlayerState == 1)
{
PlayerAnimSec.animation("Walk Animation").speed = CharacterMag / WalkingSpeed;
PlayerAnimSec.animation.CrossFade("Walk Animation", 0.4);
PlayerMotor.movement.maxForwardSpeed = WalkingSpeed;
PlayerMotor.movement.maxBackwardsSpeed = WalkingSpeed / 2;
PlayerMotor.movement.maxSidewaysSpeed = WalkingSpeed;
}
else if(PlayerState == 2)
{
PlayerAnimSec.animation("Sprint Animation").speed = CharacterMag / SprintingSpeed;
PlayerAnimSec.animation.CrossFade("Sprint Animation", 0.4);
PlayerMotor.movement.maxForwardSpeed = SprintingSpeed;
PlayerMotor.movement.maxBackwardsSpeed = SprintingSpeed / 2;
PlayerMotor.movement.maxSidewaysSpeed = SprintingSpeed;
}
Please help. I can't find the answer anywhere....
Comment
Can you tell me how you have fixed this , bcoz i m having the same problem!!!
Your answer
Follow this Question
Related Questions
First time open error android game 0 Answers
OnMouseEnter Error 1 Answer
Sound system not working correctly 0 Answers
Collectible/Counter Script Error 1 Answer