Need some scripting help

Hello I am new to scripting I could do with some help.

I am creating a game which is a modified version of the roller ball tutorial, basically I want a script that counts the cubes as they are knocked off the plane. So if they pass by a certain set of coordinates for example it counts up.

I am just looking for some example code and functions that I can work with.

Thanks for any help.

You could put a trigger below your plane and add the OnTriggerEnter function to your cube’s script. Then add a tag to the trigger and check in the cubes OnTriggerEnter function, if the trigger object is tagged with that tag. If so, you can increment your counter by 1.

Second way to do this, check on every cube whether it’s y-coordinates are less than a certain value and if so, increment your counter by 1. But this needs some more control as you also need to stop it from counting, either by disabling/destroying the cubes in the same frame or by adding another boolean for the control of the counting.

Thanks I will look into those two options.