49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PlayerController : MonoBehaviour
|
|
{
|
|
public static PlayerController instance;
|
|
public float movementSpeed = 10;
|
|
public float turningSpeed = 1;
|
|
public float turningSmoothness = 0.5f;
|
|
public float turningRotation = 20;
|
|
public float turningForce = 0;
|
|
|
|
void Awake(){
|
|
instance =this;
|
|
}
|
|
|
|
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void FixedUpdate()
|
|
{
|
|
// transform.Translate(Vector3.forward * movementSpeed);
|
|
transform.position += new Vector3(0,0, movementSpeed);
|
|
turningForce = Mathf.Lerp(turningForce, input*turningSpeed, turningSmoothness);
|
|
// transform.Translate(Vector3.right * turningForce);
|
|
transform.position += new Vector3(turningForce,0,0);
|
|
|
|
transform.localEulerAngles = new Vector3(0,0, turningForce * turningRotation);
|
|
}
|
|
|
|
float input = 0;
|
|
public void OnLeftPanel(){
|
|
input = -1;
|
|
}
|
|
|
|
public void OnRightPanel(){
|
|
input = 1;
|
|
}
|
|
|
|
public void OnPanelOff(){
|
|
input =0;
|
|
}
|
|
}
|