Wondering if anyone can help with being able to change a variable with a click of a button from a script.
I have added a pic and I want to change the suspension distance up and down with buttons.
Any help would be great, thanks!!
Wondering if anyone can help with being able to change a variable with a click of a button from a script.
I have added a pic and I want to change the suspension distance up and down with buttons.
Any help would be great, thanks!!
Add this function to some random code
public void ChangeSuspention (int amt) {
FindObjectOfType<OtherScriptName>().SuspentionDistance += amt;
}
and in your button, there should be a box saying “On Click ()”. Hit the plus sign, drag the gameobject with the script you added the function to into the box that says “None (GameObject)”, and then navigate the dropdown. Your path should look like this:
Script Name>ChangeSuspention ()
Finally, a box should have appeared. Type in the amount you want to change it.
This answer was super lengthy, but I hope it helped!