Hello! I’m creating a small 2 game (For my first time) which consists of a Duck picking up lettuces that spawns from the sky (with Instantiate) but if the player doesn’t pick up the lettuce before it hits the ground you will lose time.
It Looks like this
The problem is i can’t reference my timer script from the spawned objects and make them lower the Time Remaining, i’ve been searching for 2-3 hours already and can’t get it to work .
(I can’t make the lettuces disappear when the player picks them up too since i don’t know how to reference the player)
I already tried doing this
TimerScript timerScript = GetComponent<TimerScript>();
timerScript.Tempsrestant -= 1f;
//Tempsrestant = RemainingTime
But i get “NullReferenceException: Object reference not set to an instance of an object
LettuceBehaviour.Update () (at Assets/Lettuces/LettuceBehaviour.cs:19)”
I really need help on that one please.
Thanks in advance.