78 lines
2.4 KiB
C#
78 lines
2.4 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using NeoFPS;
|
|||
|
using NeoCC;
|
|||
|
using NeoFPS.SinglePlayer;
|
|||
|
using NeoFPS.CharacterMotion;
|
|||
|
|
|||
|
public class NeoFPSAnimationController : MonoBehaviour
|
|||
|
{
|
|||
|
public Animator animator;
|
|||
|
public MotionController mc;
|
|||
|
private NeoCharacterController ncc;
|
|||
|
//private MotionController icm;
|
|||
|
public enum AnimationState { Reloading, Jump, Walk, Idle, Run, Crouch }
|
|||
|
public AnimationState state = AnimationState.Idle;
|
|||
|
|
|||
|
// Start is called before the first frame update
|
|||
|
void Start()
|
|||
|
{
|
|||
|
mc = GetComponent<MotionController>();
|
|||
|
ncc = GetComponent<NeoCharacterController>();
|
|||
|
//icm = GetComponent<InputCharacterMotion>();
|
|||
|
}
|
|||
|
|
|||
|
// Update is called once per frame
|
|||
|
void Update()
|
|||
|
{
|
|||
|
// TODO: input is temporary solution. We need to fully utilize
|
|||
|
/*if (Input.GetKeyDown(KeyCode.R))
|
|||
|
{
|
|||
|
animator.Play("Reloading");
|
|||
|
state = AnimationState.Reloading;
|
|||
|
}
|
|||
|
else if (Input.GetKeyDown(KeyCode.Space))
|
|||
|
{
|
|||
|
animator.Play("Jump");
|
|||
|
state = AnimationState.Jump;
|
|||
|
}
|
|||
|
else if (ncc.isGrounded || (state != AnimationState.Jump && state != AnimationState.Reloading))
|
|||
|
{
|
|||
|
if (Input.GetKeyDown(KeyCode.LeftControl))
|
|||
|
{
|
|||
|
animator.Play("Crouch");
|
|||
|
state = AnimationState.Crouch;
|
|||
|
}
|
|||
|
else if (Input.GetKeyDown(KeyCode.LeftShift))
|
|||
|
{
|
|||
|
animator.Play("Run");
|
|||
|
state = AnimationState.Run;
|
|||
|
}
|
|||
|
else if(ncc.velocity.magnitude > .1f)
|
|||
|
{
|
|||
|
animator.Play("Walk");
|
|||
|
state = AnimationState.Walk;
|
|||
|
}
|
|||
|
else if(state != AnimationState.Reloading)
|
|||
|
{
|
|||
|
animator.Play("Idle");
|
|||
|
state = AnimationState.Idle;
|
|||
|
}
|
|||
|
}*/
|
|||
|
if (Input.GetKeyDown(KeyCode.R))
|
|||
|
{
|
|||
|
animator.SetTrigger("Reload");
|
|||
|
}
|
|||
|
else if (Input.GetKeyDown(KeyCode.Space))
|
|||
|
{
|
|||
|
animator.SetTrigger("Jump");
|
|||
|
}
|
|||
|
|
|||
|
animator.SetFloat("Velocity", new Vector2(ncc.velocity.x, ncc.velocity.z).magnitude);
|
|||
|
animator.SetBool("Grounded", ncc.isGrounded);
|
|||
|
animator.SetBool("Sprinting", mc.motionGraph.GetSwitch("sprint"));
|
|||
|
animator.SetBool("Crouching", mc.motionGraph.GetSwitch("crouch"));
|
|||
|
}
|
|||
|
}
|