Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | imekon |
I have a 3D spatial object that rotates about the Y axis:
core.rotate_y(3 * delta)
I also want it to move to the left or right (i.e. along the x axis), so I do the following:
var x = 0
if Input.is_action_pressed("ui_left"):
x -= delta * 10
if Input.is_action_pressed("ui_right"):
x += delta * 10
if x < -4:
x = -4
if x > 4:
x = 4
core.translate(Vector3(x, 0, 0))
Instead of it spinning and moving left or right, it moves in a circle instead of a straight line. If I choose a different axis (say y or z) then the translate makes sense.
How do I get the object to spin about the y axis and move a long the x axis controlled by the left/right arrow keys?