ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Codigo SCRIP C# movimiento y animacion de personaje


Enviado por   •  8 de Mayo de 2019  •  Tarea  •  1.064 Palabras (5 Páginas)  •  177 Visitas

Página 1 de 5

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))

{

jump = true;

currentState = STATES.JUMP;

}

}

void Idle()

{

anim.SetInteger("state", 0);

}

void Walking()

{

anim.SetInteger("state", 1);

transform.Translate(0, 0, moveSpeed * Time.deltaTime);

}

void WalkingBack()

{

anim.SetInteger("state", 3);

transform.Translate(0, 0, -moveSpeedBack * Time.deltaTime);

}

void Run()

{

anim.SetInteger("state", 2);

transform.Translate(0, 0, moveSpeed2 * Time.deltaTime);

}

void Jump()

{

anim.SetInteger("state", 4);

transform.Translate(0, 30 * Time.deltaTime,0);

// rb.AddForce(new Vector3(0, 0, 0));

}

void

...

Descargar como (para miembros actualizados) txt (3 Kb) pdf (32 Kb) docx (9 Kb)
Leer 4 páginas más »
Disponible sólo en Clubensayos.com