Advertisement
LeeMace

Plane move and Rotate Up and Down

Nov 29th, 2022
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayerControllerX : MonoBehaviour
  6. {
  7.     public float speed = 15.0f;
  8.     public float rotationSpeed = 300.0f;
  9.     public float verticalInput = 1000.0f;
  10.    
  11.  
  12.     // Start is called before the first frame update
  13.     void Start()
  14.     {
  15.  
  16.     }
  17.  
  18.     // Update is called once per frame
  19.     void FixedUpdate()
  20.     {
  21.         // get the user's vertical input
  22.         verticalInput = Input.GetAxis("Vertical");
  23.  
  24.         // move the plane forward at a constant rate
  25.         transform.Translate(Vector3.forward * speed * Time.deltaTime);
  26.  
  27.         // tilt the plane up/down based on up/down arrow keys
  28.         transform.Rotate(Vector3.right * rotationSpeed * Time.deltaTime * verticalInput);
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement