hello i have this cube that should turn to true when my ball steps on it but it’s not turning true
only if i print it to console. why is it not turning to true?
https://paste.ofcode.org/cUMCLyE3phKK64t9NnBCMH - Cube Script
https://paste.ofcode.org/bRPNBa2h39DDTKTLhhzWj6 - True Script
cmyd
October 28, 2019, 8:29am
2
I don’t you enabling/disabling the ball, All I see is in CountDown script you’re destroying the ball.
Please use Code Tags and then paste the code here.
I’m not trying to disable the ball I’m trying to make the timer show on the screen
cmyd
October 28, 2019, 10:15am
5
In your StartCountDown function at the top Debug currentTime && timeLeft and another Debug in the if condition to see if it working.
DominoM
October 28, 2019, 10:55am
6
Is there a Rigidbody on the ball?
Unity - Manual: Introduction to collision has a table of what combinations of colliders work together to fire events.
You could rework your countdown script to do everything in the co-routine and instead of setting a flag on it, call countdown.StartCountdown(countdownSeconds)
something like:
public void StartCountDown(float countdownSeconds)
{
showCountDown.SetActive(true);
showNumberCountDown.SetActive(true);
displayTimeText.text = ("Ball Destroying in: ");
StartCoroutine(DoCountDown(countdownSeconds));
}
IEnumerator DoCountDown(float timeLeft)
{
while(timeLeft > 0.0f){
timeLeft -= Time.deltaTime;
numberCountDownText.text = Mathf.Round(timeLeft).ToString();
yield return null;
}
Destroy(ball);
yield return new WaitForSeconds(delayReloadingScene);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
Edit: sorry for all the edits… kept hitting tab and accidentally saving while I was still typing
sorry i already fixed this
i appreciate the help anyway
cmyd:
Where was the problem?
i was getting a component with getcomponent where the gameobject hadn’t that
component i had to findobjectoftype