SHARE
TWEET

Untitled

a guest Nov 12th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2.  
  3. public class Cannon : MonoBehaviour
  4. {
  5.     public Rigidbody m_Rigidbody = null;
  6.  
  7.     private void Start()
  8.     {
  9.         this.m_Rigidbody = GetComponent<Rigidbody>();
  10.     }
  11.  
  12.     private void InitPosition()
  13.     {
  14.         m_Rigidbody.position = new Vector3(4f, 0.5f, 0f);
  15.     }
  16.  
  17.     private void Update()
  18.     {
  19.         if(Input.GetKeyUp(KeyCode.Return))
  20.         {
  21.             m_Rigidbody.AddForce(Vector3.left * 10f, ForceMode.Impulse);
  22.         }
  23.  
  24.         if (Input.GetKeyUp(KeyCode.Backspace))
  25.         {
  26.             InitPosition();
  27.         }
  28.     }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top