You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
848 B

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);
}
}
}