2

Why does gifs disappear before it loops again? there is a frame where after the gif animation is done it disappears and loops the gif again,

from ursina import *

app = Ursina()

enemy = Entity(model="quad", position=(3, 0), scale=(1, 1), collider="box")

class Player1(Entity):

    def __init__(self, hp, attack, level, walking_gif, standing_gif,backwalking_gif, position) -> None:

        super().__init__()

        self.hp = hp

        self.attack = attack

        self.level = level

        self.position = position

        self.walking = Animation(

            walking_gif,

            position=position,

            scale=(1, 1),

            fps=60,

            loop=True,

            autoplay=True,

            parent=self,

        )

        self.standing = Animation(

            standing_gif,

            position=position,

            scale=(1, 1),

            fps=60,

            loop=True,

            autoplay=True,

            parent=self,

        )

        self.backwalking = Animation(backwalking_gif, position=position,scale=(1, 1),fps=60,loop=True,autoplay=True,parent=self,)

    def disable_gif (self):

        self.walking.enabled = False

        self.backwalking.enabled = False

        self.standing.enabled = False

    def update(self):

        player_ray = raycast(

            self.position, (1, 0, 0), ignore=(self,), distance=0.6, debug=True

        )

        player_ray_back = raycast(

            self.position, (-1, 0, 0), ignore=(self,), distance=0.6, debug=True)

        

        player_ray_under = raycast(

            self.position, (0, -1, 0), ignore=(self,), distance=0.6, debug=True)

        if held_keys["d"] and not player_ray.hit:

            self.disable_gif()

            self.walking.enabled = True

            self.x += 0.2

        elif held_keys["a"] and not player_ray_back.hit:

            self.disable_gif()

            self.backwalking.enabled = True

            self.x -= 0.2

        

        elif held_keys["space"]:

            self.y+=0.2

        elif held_keys["s"] and not player_ray_under:

            self.y-=0.2

        else:

            self.disable_gif()

            self.standing.enabled = True

player1 = Player1(

    100,

    50,

    10,

    "Subzero_movements\subzero_walking_forward.gif",

    "Subzero_movements\Subzero_Standning_stance.gif",

    "Subzero_movements\Subzero_walking_back.gif",

    (0, 0, 0),

)

def update():

    # camera.position.x = player1.xm

    camera.parent = player1

app.run()

#ladda ner hitting gifs och lägga de i attribut

D.L
  • 4,339
  • 5
  • 22
  • 45
7MO0Di
  • 21
  • 1

0 Answers0