Codigo SCRIP C# movimiento y animacion de personaje
Enviado por LuisCS28 • 8 de Mayo de 2019 • Tareas • 1.064 Palabras (5 Páginas) • 172 Visitas
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MovimientoPC : MonoBehaviour
{
public Rigidbody rb;
public bool jump;
public float moveSpeed;
public float moveSpeed2;
public float moveSpeedBack;//movimiento del objeto
Animator anim;
CapsuleCollider col;
STATES currentState;
public bool vivo = true;
enum STATES//animaciones
{
IDLE,
WALKING,
WALKINGBack,
RUN,
JUMP,
}
void Start()
{
rb = GetComponent<Rigidbody>();
anim = GetComponent<Animator>();
currentState = STATES.IDLE;
col = GetComponent<CapsuleCollider>();
jump = false;
}
void Update()
{
CheckConditions();
MakeBehaviour();
}
void CheckConditions()
{
if (vivo)
{
if (Input.GetKey(KeyCode.LeftShift))
{
currentState = STATES.RUN;
}
else if (Input.GetKey(KeyCode.W))
{
currentState = STATES.WALKING;
}
else if (Input.GetKey(KeyCode.S))
{
currentState = STATES.WALKINGBack;
}
else currentState = STATES.IDLE;
}
else
{
currentState = STATES.IDLE;
}
if (Input.GetKeyDown(KeyCode.Space))
...