Quantcast
Channel: Answers by "ThePersister"
Viewing all articles
Browse latest Browse all 99

Answer by ThePersister

$
0
0
Oh, this was actually a lot easier than I expected, haha. If you want to rotate as long a you have your MouseButtonDown, then, instead of using "GetMouseButtonDown(0)" (which only calls once per click) use "GetMouseButton(0)" (which keeps being entered for as long as the button is down) Which gives you the code: void Update () { // rotate at 90 degrees per second if(Input.GetMouseButton(0)) { transform.Rotate(Vector3.up *Time.deltaTime*90); } } If you'd like a Random Rotation hur and thur, you can use Random.Range. Let's also add a RotationSpeed variable so you won't have to edit it in multiple different places. Here's some quick example code: public float RotationSpeed = 90f; void Update () { // Enter whilst the Left MouseButton is held down if(Input.GetMouseButton(0)) { // Rotate over x, y and z with a speed between 0 and 40 * RotationSpeed // Warning: This will give some serious wacky rotating // You can get rid of some Axis if you want, turning them to 0, to not rotate over that Axis transform.Rotate(Random.Range(0,40) * Time.deltaTime * RotationSpeed, Random.Range(0,40) * Time.deltaTime * RotationSpeed, Random.Range(0,40) * Time.deltaTime * RotationSpeed); } } I hope that helps, if you have any more specific questions, feel free to ask, otherwise, please accept this answer :)

Viewing all articles
Browse latest Browse all 99

Trending Articles



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