initial upload
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
[AddComponentMenu("Character/FPS Input Controller")]
|
||||
[RequireComponent(typeof(CharacterMotor))]
|
||||
public class FPSInputController : MonoBehaviour
|
||||
{
|
||||
private CharacterMotor motor;
|
||||
|
||||
public virtual void Awake()
|
||||
{
|
||||
if (GetComponent<NetworkView>().isMine)
|
||||
{
|
||||
motor = (CharacterMotor)GetComponent(typeof(CharacterMotor));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
if (GetComponent<NetworkView>().isMine)
|
||||
{
|
||||
Vector3 vector = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical"));
|
||||
if (vector != Vector3.zero)
|
||||
{
|
||||
float magnitude = vector.magnitude;
|
||||
vector /= magnitude;
|
||||
magnitude = Mathf.Min(1f, magnitude);
|
||||
magnitude *= magnitude;
|
||||
vector *= magnitude;
|
||||
}
|
||||
motor.inputMoveDirection = transform.rotation * vector;
|
||||
motor.inputJump = Input.GetButton("Jump");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Main()
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user