Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class YAxisMovement : MonoBehaviour {
  6.  
  7.     public float Thrust;
  8.     public Rigidbody RB;
  9.  
  10.     void Start()
  11.     {
  12.         RB = GetComponent<Rigidbody>();  
  13.     }
  14.  
  15.     void Update()
  16.     {
  17.        
  18.         if (Input.GetKeyDown(KeyCode.B))
  19.         {
  20.           RB.AddForce(transform.up * Thrust);
  21.  
  22.         }
  23.  
  24.         else
  25.         {
  26.             Thrust = 900.0f;
  27.  
  28.         }
  29.     }
  30.    
  31. }
  32. // needs to follow the playercontroller for x and z
  33. // player controller needs to follow it for the y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement