Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Cannon : MonoBehaviour
- {
- public Rigidbody m_Rigidbody = null;
- private void Start()
- {
- this.m_Rigidbody = GetComponent<Rigidbody>();
- }
- private void InitPosition()
- {
- m_Rigidbody.position = new Vector3(4f, 0.5f, 0f);
- }
- private void Update()
- {
- if(Input.GetKeyUp(KeyCode.Return))
- {
- m_Rigidbody.AddForce(Vector3.left * 10f, ForceMode.Impulse);
- }
- if (Input.GetKeyUp(KeyCode.Backspace))
- {
- InitPosition();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement