Add input controller and malon model (i think)
This commit is contained in:
26
Assets/Scripts/CharacterInputController.cs
Normal file
26
Assets/Scripts/CharacterInputController.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Scampz.GameJam.Assets.Scripts
|
||||
{
|
||||
public class CharacterInputController : MonoBehaviour
|
||||
{
|
||||
private CharacterController _controller;
|
||||
public float Speed = 5f;
|
||||
public float RotateSpeed = 3.0f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_controller = GetComponent<CharacterController>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Rotation
|
||||
transform.Rotate(0, Input.GetAxis(InputOptions.Horizontal) * RotateSpeed, 0);
|
||||
// Move
|
||||
var forward = transform.TransformDirection(Vector3.forward);
|
||||
var curSpeed = Speed * Input.GetAxis(InputOptions.Vertical);
|
||||
_controller.SimpleMove(forward * curSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user