Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.69 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class PlayerMovementStriker : MonoBehaviour
  7. {
  8.  
  9.     public float speed = 0f;
  10.     public float rotation = 360f;
  11.     public float health = 0f;
  12.     public float hull = 0f;
  13.     public float rotationspeed = 0f;
  14.     public float rotate = 0f;
  15.     public float axes = 0f;
  16.     //public float xAngle;
  17.     float n = 0;
  18.     public GameObject Turbo;
  19.     public float maxSpeed = 20f;
  20.     public float minSpeed = 0f;
  21.    
  22.    
  23.     //private Vector3 moveVector1;
  24.     //private Vector3 moveVector2;
  25.     private Vector3 moveVector3;
  26.     //private Vector3 moveVector4;
  27.  
  28.     void Start()
  29.     {
  30.       Turbo.SetActive(false);
  31.         if (GetComponent<Rigidbody>())
  32.             GetComponent<Rigidbody>().freezeRotation = true;
  33.     }
  34.  
  35.     // Update is called once per frame
  36.     void Update()
  37.     {
  38.         //float rotation1 = Input.GetAxis("Horizontal") * speed;
  39.         //float rotation = Input.GetAxis("Vertical") * speed;
  40.       if (Input.GetKey(KeyCode.W))
  41.         {
  42.             transform.Rotate(rotationDirection * rotationspeed);
  43.         }
  44.       if (Input.GetKey(KeyCode.S))
  45.         {
  46.             transform.Rotate(rotationDirection1 * rotationspeed);
  47.         }
  48.       if (Input.GetKey(KeyCode.D))
  49.         {
  50.             transform.Rotate(rotationDirection2 * rotate);
  51.         }
  52.       if (Input.GetKey(KeyCode.A))
  53.         {
  54.             transform.Rotate(rotationDirection3 * rotate);
  55.         }
  56.       if (Input.GetKey(KeyCode.E))
  57.         {
  58.             transform.Rotate(rotationDirectione * axes);
  59.         }
  60.       if (Input.GetKey(KeyCode.Q))
  61.         {
  62.             transform.Rotate(rotationDirectionq * axes);
  63.         }
  64.      
  65.      
  66.           //Turbo
  67.       if (Input.GetKeyDown(KeyCode.Space))
  68.         {
  69.           n += 50f;
  70.           maxSpeed = 70f;
  71.           Turbo.SetActive(true);
  72.         }
  73.       else if (Input.GetKeyUp(KeyCode.Space))
  74.         {
  75.           n -= 50f;
  76.           Turbo.SetActive(false);
  77.           maxSpeed = 20f;
  78.           n = Mathf.Clamp(n, minSpeed, maxSpeed);
  79.         }
  80.      
  81.  
  82.      
  83.       n = Mathf.Clamp(n, minSpeed, maxSpeed);
  84.       n += Input.GetAxis("Mouse ScrollWheel");
  85.  
  86.         //prevents value from exceeding specified range
  87.  
  88.        
  89.  
  90.         Debug.Log(n);
  91.        
  92.        
  93.  
  94.        
  95.  
  96.         //moveVector1 = new Vector3(0, rotation1, 0);
  97.         //moveVector2 = new Vector3(0, 0, rotation);
  98.         //flugrichtung
  99.         moveVector3 = new Vector3(0, 0, n);
  100.         //moveVector4 = new Vector3(0, 0, zDir);
  101.  
  102.         //transform.Translate(moveVector1);
  103.         //transform.Translate(moveVector2);
  104.         transform.Translate(moveVector3);
  105.         //  transform.Translate(moveVector4);
  106.  
  107.        
  108.     }
  109.  
  110.  
  111.     public void setRotationDirection(Vector3 rotation)
  112.     {
  113.         rotationDirection = rotation;
  114.         rotationDirection1 = rotation;
  115.     }
  116.  
  117.     public Vector3 getRotationDirection()
  118.     {
  119.         return rotationDirection;
  120.     }
  121.  
  122.     //Rotates the object.
  123.     void FixedUpdate()
  124.     {
  125.         //transform.Rotate(rotationDirection * rotationspeed);
  126.     }
  127.  
  128.     // W
  129.     [SerializeField]
  130.     private Vector3 rotationDirection = new Vector3(0, 0, 0);
  131.     //S
  132.     [SerializeField]
  133.     private Vector3 rotationDirection1 = new Vector3(0, 0, 0);
  134.     //A
  135.     [SerializeField]
  136.     private Vector3 rotationDirection2 = new Vector3(0, 0, 0);
  137.     //D
  138.     [SerializeField]
  139.     private Vector3 rotationDirection3 = new Vector3(0, 0, 0);
  140.     //Q
  141.     [SerializeField]
  142.     private Vector3 rotationDirectionq = new Vector3(0, 0, 0);
  143.     //E
  144.     [SerializeField]
  145.     private Vector3 rotationDirectione = new Vector3(0, 0, 0);
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement