I’m on video 43 of the Complete C# Unity Game Developer 2D where we use FindObjectOfType to edit the Surface Effector 2D property on the snow. This includes serializing some values for the speed of the surface, which overrides the original value on the SE2D component that the surface had.
I was wondering if this was good/standard/non-problematic practice. Should I not really worry about overriding component’s values through scripts that live on other objects?
I’d appreciate the input!
Thank you <3
Hi! Welcome to the community!
When dealing with Unity’s in-build components there aren’t a lot of issues and is kinda encouraged to change those settings via a script, even Unity official tutorials do that a lot, and actually, you do that to move objects, you are constantly changing the Transform
component’s values and there’s no issue, same when using Rigidbodies
, so you might say it’s pretty standard to change values through scripts.
Keep in mind, modifying a value via scripts removes the ability to test said value in real-time, especially if you are doing it constantly, like on every Update tick. That’s something you want to consider before touching any value, not just Unity’s in-build components, but any value you might have on other scripts.
Hope this helps!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.