i need to stop doing something once a cube is too small
I need help I have a simple script that increases the size of a target object if you click and hold a button if there is a max size variable that stops the scaling once the target object is almost at that size if you are increasing the size it works but if you are lowering the size it goes forever into negative using UnityEngine; using System.Collections; public class ScaleButton : MonoBehaviour { %|-1784374363_1|% %|1496128269_2|% %|-1359922501_3|% %|-2049047649_4|% %|-1348667168_5|% %|-964950395_6|% %|1428995887_7|% isMaxSize = true; %|-1985573301_9|% %|1380323385_10|% %|2136210357_11|% %|-206416969_12|% %|749266888_13|% %|-660687095_14|% %|295417773_15|% %|-2084710974_16|% } }
here is my code it must of bugged out while posting using UnityEngine; using System.Collections; public class ScaleButton : $$anonymous$$onoBehaviour { public Transform objectToScale; public Vector3 size; public Vector3 stopPoint; public float scaleSpeed; bool is$$anonymous$$axSize; %|-727809232_6|% if (objectToScale.localScale.magnitude - stopPoint.magnitude >= 0.5f) { is$$anonymous$$axSize = true; } else { is$$anonymous$$axSize = false; } } void On$$anonymous$$ouseDrag(){ if (!is$$anonymous$$axSize) { objectToScale.localScale += size * scaleSpeed * Time.deltaTime; %|-1922774728_16|% %|-132809280_17|% }
Your answer
Follow this Question
Related Questions
Content Size Fitter should scale only in one direction 0 Answers
why did the script change 0 Answers
Scaling a text to fill 50% of screen width and 50% of height, no matter whats inside C# 0 Answers
If statement not getting called after Lerping a Scale 1 Answer
Smooth scale Object every second 1 Answer