[SOLVED] Sprite vanishing after first animation loop

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
DuoDynamo2
Posts: 4
Joined: Mon Dec 05, 2022 12:49 pm

[SOLVED] Sprite vanishing after first animation loop

Post by DuoDynamo2 »

I'm trying to replace the stimpack's graphic with a custom animated sprite. In-game, the first loop displays correctly; but after the first loop, instead of replaying the animation, the sprite simply disappears. The item is still there and can be picked up, but it's invisible.

This is the code I'm using:
Spoiler:
What's funny is that I used almost the same code for the health bonus, and that one is looping properly:
Spoiler:
My wild guess it has something to do with the fact that the default health bonus sprite is already animated (as opposed to the static stimpack sprite), but I still don't know exactly what's causing the issue.

Thanks in advance.
Last edited by DuoDynamo2 on Fri Dec 09, 2022 2:53 pm, edited 1 time in total.
User avatar
Player701
 
 
Posts: 1522
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Location: Russia

Re: Sprite vanishing after first animation loop

Post by Player701 »

Your first example works fine for me when copied verbatim (even though I don't have the extra STIM sprites, so I see the item blinking in and out of existence all the time).

First, please make sure you're using the latest GZDoom release (4.10.0 as of now). If you still get this problem, please post your entire mod here so that it can be investigated further.
User avatar
DuoDynamo2
Posts: 4
Joined: Mon Dec 05, 2022 12:49 pm

Re: Sprite vanishing after first animation loop

Post by DuoDynamo2 »

Player701 wrote: Thu Dec 08, 2022 4:57 am I see the item blinking in and out of existence all the time
Yeah, when I first tried out the code I hadn't replaced the graphics yet, and I also got the blinking stimpack.
I have updated GZDoom to version 4.10.0, but the issue still persists.

Here's a link to the mod.

Thanks again!
Last edited by DuoDynamo2 on Thu Dec 08, 2022 4:41 pm, edited 1 time in total.
User avatar
Player701
 
 
Posts: 1522
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Location: Russia

Re: Sprite vanishing after first animation loop

Post by Player701 »

You haven't set up the proper offsets for your STIM sprites. You need to use a tool such as SLADE or grabpng to edit the sprite files and assign the offsets.

The weird thing here is that you can see the sprite at all, even if only for a few ticks. Might be a bug, or one of those quirks of the GZDoom engine that were left in to avoid breaking existing mods that rely on them.
User avatar
DuoDynamo2
Posts: 4
Joined: Mon Dec 05, 2022 12:49 pm

Re: Sprite vanishing after first animation loop

Post by DuoDynamo2 »

*facepalm* Duh, of course. It was the offset.
I'm using SLADE, but I keep forgetting about the offset. Normally when I get an invisible sprite I remember about it straight away, but I guess I was thrown off this time because of the first frames showing up. Made me think it was something else.
I adjusted the offset and now it's working as intended. Thank you very much for the help!

Return to “Scripting”