Visual Scripting In Unity : Rotate an object

Here are variations on how to rotate an object using visual scripting. For this demonstration I made two cubes rotate automatically as well as via user input. One will rotate using the XBox controller and the other one is controlled using keyboard.

Continuous rotate at a set rate of degrees per second

In the Scripting Graph Blackboard, initialize object variables for rotation degrees per second and amount to rotate per frame.

Then you can use the On Update event handler to set the amount to rotate this frame as the transform to rotate the cube.

Rotate based on joystick X axis input

In the Scripting Graph Blackboard, initialize object variables for the horizontal joystick input and rotation degrees per second – the amount to rotate per frame,.

Use the On Update event node to get the Joystick input axis value

Set the horizontal joystick object variable and then do some math to create a float  to send to the rotate transform

Your finished script will look like this. the cube will rotate at a speed that varies based on the sensitivity of your joystick controller. I recommend the Xbox series s 🙂

Leave a Reply