• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

change animaton and speed

D

discocar

Guest
so I have an item and when the npc collects the item it will change its animation and speed.

at the moment the NPCs ai is like this

case 1:
// move right
image_xscale=1;
image_speed = 0.1;
sprite_index=sprite20;
speed = 1;
direction = 0;
move_hold = 1;
break;
case 2:
// move left
image_xscale=-1;
image_speed = 0.1;
sprite_index=sprite21;
speed = 1;
direction = 180;
move_hold = 1;
break;

when the npc collects the item to increase its speed I would need to do something like npc collides with the item

speed += 2

but how would I go about changing the sprite animation?

Thanks
 

TsukaYuriko

☄️
Forum Staff
Moderator
sprite_index controls the sprite of the instance. If you add an extra check that tells you whether the NPC picked up the item or not, you can assign the correct sprite accordingly.

Or is that not what you meant? If it isn't, I'm unsure what you mean by "changing the sprite animation".
 

curato

Member
you could change the sprite_index to a running sprite or change increase image_speed depending on what result you are going for.
 
Top