Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Can I use one script but in many Game Objects?

A topic by alexsilent created Sep 29, 2019 Views: 220 Replies: 2
Viewing posts 1 to 2
(2 edits)

Can I use one script for many objects on levels?
Just for example: I have 1000 game objects on the level, and 1000 scripts with one name "MyScript"
(Because I don't know how to check  "OnCollisionStay2D" from other Game Object, I need that script on the current object. )
PS I'm sorry for my bad English.

Jam HostSubmitted

As long as you only have one script file in your entire project then you are free to do this however you want. You can either create a script of which only one instance will exist, and in this case that one instance of the script would control the entire game. Another approach is to write one single script that you have multiple instances of, setting it up so that only the necessary data relative to the functionality required of that particular instance needs to be specified.

Thanks!