Thank you for the quick answer. Before continuing my explanation further, I’d like to apologize as I just noticed that I miss-wrote the name of the object I was looking for. I’ll fix it here so it makes more sense in the context of my question.
What I meant earlier was that I’m looking for two separate Level Sprite Terrains which are the Sprite Shapes with the added surface effector. (I am unsure what was I thinking when I wrote “Sprite Text”… Sorry about that.)
Anyway, here’s the follow up:
The way I’m trying to make it work with multiple surface effectors is by adding them in an array (experimented with both FindObjectsOfType<>
and just by adding them in the inspector for learning’s sake, both worked, so yay for that!) and the only way I could figure out about defining the speed value was this way…
srfcEffArr[0].speed = boostSpeed;
srfcEffArr[1].speed = boostSpeed;
…which works, but surely there must be a better way to define the speed variables than writing over every single cell in the array?
Also if I decide to use FindObjectsOfType
instead, and there’s less surface effectors in a level, the console will print IndexOutOfRangeException errors. I get why, the code wants to define speed variables of things don’t exist in the current context and that breaks the code.
So I guess I have two questions:
- Is there a better way to define speed variables in an array?
- If using
FindObjectsOfType
, how can one define speed variables without getting an out of bounds error in the array?