Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement