Quantcast
Channel: Latest Questions by Red Sentinel
Viewing all articles
Browse latest Browse all 38

Setting the value of a var to the value of another

$
0
0
Hi everyone. I am having a problem of setting the value of one variable to the value of another. This is my script: var MaxArmourValue = 3; var MinArmourValue = 1; var CurrentArmourValue = 1; var HelmSelection = CurrentArmourValue; function OnGUI(){ GUI.Box (Rect (420,10,250,90), "Helmet "+ HelmSelection); if (GUI.Button (Rect (600, 20, 50, 20), ">")) { HelmSelection +=CurrentArmourValue; } if (HelmSelection > MaxArmourValue){ HelmSelection = MinArmourValue; } else if (HelmSelection < MinArmourValue); { HelmSelection = MaxArmourValue; } if (GUI.Button (Rect (440, 20, 50, 20), "<")) { HelmSelection -=CurrentArmourValue; } if (GUI.Button (Rect (495, 50, 100, 20), "Accept")) { } } What I want to do is when the > or < buttons are pressed, the rectangle will show "Helmet 1/2/3" etc. This works but I don't know how to stop the values from going over 3 and below 1. All help is appreciated.

Viewing all articles
Browse latest Browse all 38

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>