If I have a variable within a Script:
public Rigidbody2d body;
I know I can use the UI to populate the above ‘body’ variable with my Rigidbody asset, but how can I dynamically define this within the script?
Thanks,
T
If I have a variable within a Script:
public Rigidbody2d body;
I know I can use the UI to populate the above ‘body’ variable with my Rigidbody asset, but how can I dynamically define this within the script?
Thanks,
T
If I understand you correctly, you want to use the GameObject.AddComponent to add a new component or GameObject.GetComponent to reference an existing one.