I want to create a class that create an Entity when is called. In this class i have an update functioun where i traied to animate the entity, but the self.animate_position_x doesn't work and i get the error: "duration" is not defined.My code is:
class enemy(Entity):
def __init__(self,x,y):
super().__init__()
self.model = 'quad'
self.color = color.green
self.collider = 'box'
self.scale = (1,2)
self.position = (x,y)
self.posx = x
def update(self):
self.animate_x = (12, duration == 1)
touch = self.intersects(ignore =(ground,player,))
dist = distance(self,player)
if touch.hit:
destroy(self,delay = 0.05)
How can i animate in a class? P.S I use Ursina engine