If I remember correctly I was told that it’s not a good idea to call another script from a script. By using GetComponent (). As it is taxing on memory or something like that. Anyone know if this is the case?
If it is, is there a less taxing way or better way to interact with a script. Or should I just try to call another script as little as possible?
This isn’t the first time this has been asked on these forums, and from experience this gets twisted into “don’t use getcomponent in update” which isn’t correct. The emphasis is on “more than you need to”.
If you are working in the Update function and working with dynamic references (for example the raycasthit from a raycast which can change from one frame to the next) and you want a component based on that reference’s current state it’s perfectly correct to use getcomponent.
If you are working in the Update function and you are using a reference that isn’t going to change (for example the rigidbody attached to this gameobject, which is never removed) you should do the getcomponent in start/awake and use the reference in the update function rather than getting the component every frame in update function.