Import existing Unity project

This commit is contained in:
2019-09-19 20:47:29 +02:00
parent adf16435c5
commit fcc2c31771
56 changed files with 4627 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public string playerNumber;
public float rotationSpeed = 100;
public float movementSpeed = 100;
public Rigidbody rb;
public GameObject forceZone;
public float boostSpeed = 0;
public float boostDuration = 0;
public float lastBoostTime = 0;
public bool lockBoost = false;
// Start is called before the first frame update
void Start()
{
this.rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
float rotationDirection = Input.GetAxis("Horizontal" + this.playerNumber);
float movementDirection = Input.GetAxis("Vertical" + this.playerNumber);
if (rotationDirection > 0)
{
transform.Rotate(Vector3.up, this.rotationSpeed * Time.deltaTime);
}
if (rotationDirection < 0)
{
transform.Rotate(Vector3.up, -this.rotationSpeed * Time.deltaTime);
}
if (movementDirection > 0)
{
this.rb.AddRelativeForce(Vector3.forward * this.movementSpeed * Time.deltaTime, ForceMode.Impulse);
}
if (movementDirection < 0)
{
this.rb.AddRelativeForce(Vector3.back * this.movementSpeed * Time.deltaTime, ForceMode.Impulse);
}
if (Input.GetButtonDown("Boost" + this.playerNumber) && !this.lockBoost)
{
this.rb.AddRelativeForce(Vector3.forward * this.boostSpeed * Time.deltaTime, ForceMode.Impulse);
this.forceZone.SetActive(true);
this.lastBoostTime = Time.time;
this.lockBoost = true;
}
if (Time.time > (this.lastBoostTime + this.boostDuration))
{
this.lockBoost = false;
this.forceZone.SetActive(false);
}
}
}