Can someone tell me what I’m doing wrong? I’m new to coding, so I’m sure I’ve overlooked something. Within the editor, I dragged the code onto my trigger object and set the correct asset within my scene as the “thwomp” GameObject. I’ve also set the correct numeric values for var changeScale. I just want to scale the “thwomp” object up and down while in the trigger.
I’m using a cube for the trigger and a mesh for the affected object. Actually I noticed now that the code is working, however it doesn’t affect what’s in the scene. It only affects the prefab within the Project hierarchy. For example, I am trying to scale the mesh while inside the trigger. Nothing happens on screen but if I go into the project window and drag that same prefab into the scene I notice that the scaling I just applied affected the prefab and the prefab is now larger than it was before. Why would this happen? Why would my scaling affect the prefab and not the actual asset within the scene?
That’s because you are directly interacting with the prefab. If the script is in the same object that you want to scale you should just use “transform.localScale” instead of “thwomp.transform.localScale”. Or instantiate it and keep the reference in a variable