AviatorUnlimited/Assets/Scripts/PlayerController.cs
2023-07-15 21:40:01 +05:30

56 lines
1.2 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);
}
void OnTriggerEnter(Collider other){
Debug.Log("Hit with " + other.name);
Application.LoadLevel(0);
}
float input = 0;
public void OnLeftPanel(){
input = -1;
}
public void OnRightPanel(){
input = 1;
}
public void OnPanelOff(){
input =0;
}
}