Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class PlayerMovementStriker : MonoBehaviour
- {
- public float speed = 0f;
- public float rotation = 360f;
- public float health = 0f;
- public float hull = 0f;
- public float rotationspeed = 0f;
- public float rotate = 0f;
- public float axes = 0f;
- //public float xAngle;
- float n = 0;
- public GameObject Turbo;
- public float maxSpeed = 20f;
- public float minSpeed = 0f;
- //private Vector3 moveVector1;
- //private Vector3 moveVector2;
- private Vector3 moveVector3;
- //private Vector3 moveVector4;
- void Start()
- {
- Turbo.SetActive(false);
- if (GetComponent<Rigidbody>())
- GetComponent<Rigidbody>().freezeRotation = true;
- }
- // Update is called once per frame
- void Update()
- {
- //float rotation1 = Input.GetAxis("Horizontal") * speed;
- //float rotation = Input.GetAxis("Vertical") * speed;
- if (Input.GetKey(KeyCode.W))
- {
- transform.Rotate(rotationDirection * rotationspeed);
- }
- if (Input.GetKey(KeyCode.S))
- {
- transform.Rotate(rotationDirection1 * rotationspeed);
- }
- if (Input.GetKey(KeyCode.D))
- {
- transform.Rotate(rotationDirection2 * rotate);
- }
- if (Input.GetKey(KeyCode.A))
- {
- transform.Rotate(rotationDirection3 * rotate);
- }
- if (Input.GetKey(KeyCode.E))
- {
- transform.Rotate(rotationDirectione * axes);
- }
- if (Input.GetKey(KeyCode.Q))
- {
- transform.Rotate(rotationDirectionq * axes);
- }
- //Turbo
- if (Input.GetKeyDown(KeyCode.Space))
- {
- n += 50f;
- maxSpeed = 70f;
- Turbo.SetActive(true);
- }
- else if (Input.GetKeyUp(KeyCode.Space))
- {
- n -= 50f;
- Turbo.SetActive(false);
- maxSpeed = 20f;
- n = Mathf.Clamp(n, minSpeed, maxSpeed);
- }
- n = Mathf.Clamp(n, minSpeed, maxSpeed);
- n += Input.GetAxis("Mouse ScrollWheel");
- //prevents value from exceeding specified range
- Debug.Log(n);
- //moveVector1 = new Vector3(0, rotation1, 0);
- //moveVector2 = new Vector3(0, 0, rotation);
- //flugrichtung
- moveVector3 = new Vector3(0, 0, n);
- //moveVector4 = new Vector3(0, 0, zDir);
- //transform.Translate(moveVector1);
- //transform.Translate(moveVector2);
- transform.Translate(moveVector3);
- // transform.Translate(moveVector4);
- }
- public void setRotationDirection(Vector3 rotation)
- {
- rotationDirection = rotation;
- rotationDirection1 = rotation;
- }
- public Vector3 getRotationDirection()
- {
- return rotationDirection;
- }
- //Rotates the object.
- void FixedUpdate()
- {
- //transform.Rotate(rotationDirection * rotationspeed);
- }
- // W
- [SerializeField]
- private Vector3 rotationDirection = new Vector3(0, 0, 0);
- //S
- [SerializeField]
- private Vector3 rotationDirection1 = new Vector3(0, 0, 0);
- //A
- [SerializeField]
- private Vector3 rotationDirection2 = new Vector3(0, 0, 0);
- //D
- [SerializeField]
- private Vector3 rotationDirection3 = new Vector3(0, 0, 0);
- //Q
- [SerializeField]
- private Vector3 rotationDirectionq = new Vector3(0, 0, 0);
- //E
- [SerializeField]
- private Vector3 rotationDirectione = new Vector3(0, 0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement