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.
 
 
 
 
 
 

42 lines
1.0 KiB

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class ShootingCannon : MonoBehaviour
{
public bool shootingRight;
public bool triggeranimate;
public GameObject shootingObject;
public Transform spawnLocation;
public TextMeshPro counter;
public int countdowntimer;
int countdown;
private void Start()
{
countdown = countdowntimer;
}
private void Update()
{
counter.text = countdown.ToString();
}
public void Animate()
{
countdown--;
if (countdown == 0){
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);
}
countdown = countdowntimer;
}
}
}