hi guys,
Trying to deternate a shell after it has been fired from my tank
it really looks like it should be working but the button wont trigger the print caption
i just cant get print(“det flak”); to print
the true false is working and i can even get into the button function but it just isnt seeing the true or false…please help
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerTankShell : MonoBehaviour
{
public ParticleSystem shellExplodes;
public AudioSource shellExplodesSound;
public DamageController damageController;
public Collider2D blastRadius;
private float timer;
private bool shellCanDetonate = false;
private void Start()
{
damageController = FindObjectOfType<DamageController>();
}
private void Update()
{
CheckShellcanDetonate();
print(shellCanDetonate);
}
private void OnTriggerEnter2D(Collider2D collider)
{
if (collider.gameObject.tag == "Player")
{
damageController.TakingDamage(10);
}
Instantiate(shellExplodes, transform.position, transform.rotation);
shellExplodesSound.Play();
Destroy(gameObject, 0.1f);
blastRadius.enabled = true;
StartCoroutine(BlastRadius());
}
void CheckShellcanDetonate()
{
timer += Time.deltaTime;
if (timer > 3)
{
shellCanDetonate = true;
}
}
public void FlackDetonate()
{
if (shellCanDetonate)
{
print("det flak");
}
}
IEnumerator BlastRadius()
{
float waiting = 0.2f;
yield return new WaitForSeconds(waiting);
blastRadius.enabled = false;
}
}