Question 1: Unity says that the lines that say:
“case Playerstate.animationname:”
have an unknown identifier “Playerstate”
#pragma strict
import UnityEngine;
import System.Collections;
@System.NonSerialized
var controller : CharacterController;
//@System.NonSerialized
//var motor : CharacterMotor;
@System.NonSerialized
var charVelocity : Vector3;
public var lockedAnimation : boolean = false;
public var isDead : boolean = false;
public enum PlayerState {
Idle,
Walking,
Running,
Jumping,
Falling,
Landing,
Dead,
Locked,
Crouching,
CrouchWalking
}
public var state : PlayerState;
public var prevState : PlayerState;
function Start () {
animation["idle"].wrapMode = WrapMode.Loop;
animation["jump_pose"].wrapMode = WrapMode.ClampForever;
animation["walk"].wrapMode = WrapMode.Loop;
animation["run"].wrapMode = WrapMode.Loop;
}
function LateUpdate () {
// I am trying to access the velocity from another script "CharacterMotor"
charVelocity = CharacterMotor.movement.velocity;
CalculateState();
ApplyState();
}
function CalculateState(){
-----------------------OMITTED------------------------------
}
function ApplyState(){
switch(state){
case Playerstate.Idle:
animation.CrossFade("idle");
break;
case Playerstate.Walking:
animation.CrossFade("walk");
break;
case Playerstate.Running:
animation.CrossFade("run");
break;
// case Playerstate.Jumping:
//
case Playerstate.Falling:
animation.CrossFade("jump_pose");
break;
// case Playerstate.Landing:
//
// case Playerstate.Dead:
//
// case Playerstate.Locked:
//
// case Playerstate.Crouching:
//
// case Playerstate.CrouchWalking:
//
}
}
prevState = state;
@script RequireComponent (CharacterMotor)
Question 2: I don’t know if I am accessing my script “CharacterMotor” correctly. in function LateUpdate. The variable movement in “CharacterMotor” is based off a class that has a component of velocity. I don’t think i can make the movement variable static because it is modified.
Thank you in advance to anybody willing to take their time to help!