Quantcast
Viewing all articles
Browse latest Browse all 154

Holding GUI Button Touch to Rotate Object

How to make an object rotates if you hold the GUI Button ? For instance : Turn Left Button, if you pressing (hold) turn left button, the object will rotates to the left till you lift your hand (TouchPhase.Ended). Here's my script if(GUILayout.Button(someTextures[10])){ if(Input.touches.Length > 0 && Input.touches[0].phase == TouchPhase.Began){ rxz = -1 * 10; rxz *= Time.deltaTime; }else if (Input.touches.Length > 0 && Input.touches[0].phase == TouchPhase.Ended) rxz = 0; //cnt.isPressing[1] = true; } rxz is float = 0. at function update() prnt.transform.Rotate(0,rxz,0); I also have a problem in launching the object for the first time. For Instance : I hold the GUI Button, it was directly become 1.50 (it should be clamping from 0 to 1.50) i don't know how to say.here's my another script if(isPressing[0]){ if(Input.touches.Length >0){ if(Input.touches[0].phase == TouchPhase.Began){ start = Time.timeSinceLevelLoad; gui.ShowMe(true); }else if(Input.touches[0].phase == TouchPhase.Ended){ end = Time.timeSinceLevelLoad; gui.ShowMe(false); hint.ShowHint(power.ToString("f2"),1.5, false); StopMe(); force = power*speed; // here you compare the 2 values I had to multiply by 20 to get it up (that's what she says) but you might have to alter this eqution to get what you want if(throwingSFX ){ audio.Stop(); audio.clip = throwingSFX[Random.Range(0,throwingSFX.length)]; audio.Play(); } } } } from another GUI Script if(GUILayout.Button(someTextures[8]))cnt.isPressing[0] = true;

Viewing all articles
Browse latest Browse all 154

Trending Articles



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