Hey, I’m making a Claw Game. I have a fbx baseclaw mesh with script (with movement, inputs and states (and a kinematic rigidbody)) added and a fbx for the claw itself with the animations added.
Here’s the code:
#pragma strict
public var clawSpeed : float = 2;
private var moveDirection : Vector3;
private var myTransform : Transform;
enum CharacterState
{
Idle,
Opening,
Lowering,
Closing,
Closed,
Raising,
RaisedClosed,
OpeningAgain,
}
var _characterState : CharacterState;
function Start ()
{
myTransform = transform;
//_characterState = CharacterState.Idle;
}
function Update ()
{
moveDirection.x = Input.GetAxis("Horizontal");
moveDirection.z = Input.GetAxis("Vertical");
moveDirection.Normalize();
myTransform.position += moveDirection * clawSpeed * Time.deltaTime;
if (Input.GetKey(KeyCode.X))
{
switch (_characterState.Idle)
{
case _characterState.Opening:
//play animation
animation.Play("Opening");
_characterState = CharacterState.Lowering;
//change state
break;
case _characterState.Lowering:
//play animation
animation.Play("Lowering");
_characterState = CharacterState.Closing;
//change state
break;
case _characterState.Closing:
//play animation
animation.Play("Closing");
_characterState = CharacterState.Closed;
//change state
break;
}
}
}
Here’s the error message:
“BCE0132: The namespace ‘’ already contains a definition for ‘CharacterState’.”
Objective: When X button is pressed one time plays “Opening” Animation, X button again plays “Lowering” Animation, X button again plays “Closing” and it keep going on.
Please help me!!