LegitTeddyBears

Speed

May 28th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Speed : MonoBehaviour {
  6.     //The Object we want to modify
  7.     public GameObject Ship;
  8.     //The name of the Script we want to modify, (OSA stands for Other Script Access)
  9.     private PlaneControl OSA;
  10.     //How much extra Speed the ship gets after pickup
  11.     public int SpeedMult;
  12.  
  13.  
  14.     // Use this for initialization
  15.     void Start ()
  16.     {
  17.         OSA = Ship.GetComponent<PlaneControl>();
  18.     }
  19.  
  20.     // OnTriggerEnter is where we dictate what happens to the object when it interacts with a rigidbody
  21.     private void OnTriggerEnter(Collider other)
  22.     {
  23.         OSA.Base_Speed = OSA.Base_Speed * SpeedMult;
  24.         gameObject.SetActive(false);
  25.     }
  26.  
  27.     // Update is called once per frame
  28.     void Update ()
  29.     {
  30.         transform.Rotate(new Vector3(0, -90, 0) * Time.deltaTime);
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment