In Python Ursina reibungslos rotierenPython

Python-Programme
Anonymous
 In Python Ursina reibungslos rotieren

Post by Anonymous »

Ich schreibe gerade ein Spiel und in einer meiner Entitätsunterklassen muss ich es "reibungslos" drehen, anstatt eine teleportierte Esque -Rotation durchzuführen. Im Moment habe ich < /p>
def smooth_look_at(self, target_position, speed = 10):
global target_rot
if not self.pass_: # only set the target rotation and the increment once per thing looked at
target_rot = (target_position - self.position)
self.increment = target_rot.y / speed
self.pass_ = True
self.rotation.y += self.increment * time.dt #only rotate around the y axis
if self.rotation == target_rot: #if you reach your rotation goal, return true, reset pass_ for the next time you need to rotate
self.pass_ = False
return True
< /code>
In der Funktion (Selbst) von Update (Selbst) wird Walk jedes Mal aufgerufen, wenn ich sie benötige, und in der Funktion Walk () gibt es eine Zeile: < /p>
if not self.smooth_look_at(self.target_position):
return
< /code>
Es wartet also, bis es sich dreht.
Was endet, ist, dass es sich nie dreht. Was mache ich falsch und wie kann ich es beheben?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post