I’m currently learning the Ursina 3d game engine module for Python. I’m attempting to write a code where you press the ‘s’ key and the cube makes a full 360 degree rotation along the x axis. Right now the code works for the first full rotation, then afterward when you press ‘s’ it only rotates by a couple degrees each time. Here is the code, I can’t figure out what is wrong exactly. Thanks so much.
from ursina import *
class Rotatebox(Button):
def __init__(self):
super().__init__()
self.model = 'cube'
self.texture = 'PlayerTrans'
self.scale = (.1,.1,.1)
self.position = (0,0,0)
self.color = color.white
self.rotation_speed = 100 # Adjust the rotation speed as desired
self.rotation_angle = 0
self.rotate = False
def update(self):
if self.rotate == True:
self.rotation_angle += self.rotation_speed * time.dt
self.rotation_x = self.rotation_angle
if self.rotation_angle >= 360:
self.rotate = False
def input(self, key):
if key == 's':
self.fullRotate()
def fullRotate(self):
if self.rotate == False:
self.rotate = True
app = Ursina()
boxrotate = Rotatebox()
app.run()