I have 2 fbx files
- running_40.fbx , see the image
A script is attached to the Soldier GO, here is the script
using UnityEngine;
using System.Collections;
public class characterScript : MonoBehaviour
{
//references
characterScript charScript;
public static float SwitchingSpeed=8.0f;
public static Vector3 pos;
public float ForwardSpeed;
public int HowFarToGo;
private bool OnLeft;
private bool OnRight;
public static bool IsSwitching;
private int counter;
public static bool ALTERNATOR, LeftOrRight;
public static CharacterController controller;
private string activeAnimation;
// move variables
public float runSpeed = 8f;
public static float hero_z_position;
public static float hero_x_position;
private int leftyes=1;
void Start ()
{
ALTERNATOR = true;
OnRight = true;
controller = gameObject.GetComponent<CharacterController>();
//Debug.Log(leftyes);
}
void OnEnable()
{
FingerGestures.OnFingerSwipe += FingerGestures_OnFingerSwipe;
}
void OnDisable()
{
FingerGestures.OnFingerSwipe -= FingerGestures_OnFingerSwipe;
}
void FingerGestures_OnFingerSwipe( int fingerIndex, Vector2 startPos, FingerGestures.SwipeDirection direction, float velocity )
{
if(direction==FingerGestures.SwipeDirection.Left leftyes==0){
leftyes=1;
Debug.Log("its left and leftyes=" +leftyes);
}
if(direction==FingerGestures.SwipeDirection.Right leftyes==1){
leftyes=0;
Debug.Log("its Right and leftyes=" +leftyes);
}
}
void Update ()
{
controller.Move(transform.forward * 8f * Time.deltaTime);
hero_z_position = transform.position.z;
hero_x_position = transform.position.x;
//Debug.Log(hero_x_position);
if(Input.GetKeyDown(KeyCode.X)){
Debug.Log("pressed x");
}
//horizontal
if (leftyes==1)
{
pos = transform.right * (-SwitchingSpeed) * Time.deltaTime;
pos.x = Mathf.Clamp(pos.x,-5.5f,5.5f);
controller.Move(pos);
}
else if (leftyes==0)
{
pos = transform.right * SwitchingSpeed * Time.deltaTime;
pos.x = Mathf.Clamp(pos.x,-5.5f,5.5f);
controller.Move(pos);
}
float newX = Mathf.Clamp(transform.position.x,-5.5f,0.5f);
transform.position = new Vector3(newX, transform.position.y, transform.position.z);
}
}
I want to play animation when button x is pressed[refer above code], which is in other fbx called SmartGuy@smart_guy_tripping.fbx
How can i do it ?