- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
-
- public class ShootingCannon : MonoBehaviour
- {
- public bool shootingRight;
- public bool triggeranimate;
- public GameObject shootingObject;
- public Transform spawnLocation;
-
- private void Update()
- {
- //for testing purposes
- if (triggeranimate == true)
- {
- Animate();
- triggeranimate = false;
- }
- }
-
- public void Animate()
- {
- GameObject shot = Instantiate(shootingObject, spawnLocation.position, Quaternion.identity);
- if (shootingRight == true)
- {
- shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * -500);
- }
- else
- {
- shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * 500);
- }
- }
- }
|