footprints

So the characters in my top-down strategy game form footprints to the ground when they move.
I've implemented the following code for the characters ('units):

Create:
canprint=1

Step:
if canprint=1
{
if !place_meeting(x,y,waterpar)
{
if speed > 0
{
instance_create(x,y,footprints)
can_print=0
alarm[0]=5
}
}
}

Alarm 0:
canprint=1

However they still keep making footprints even when they are still, that is, their speed is 0. Every unit has a variable 'spd' to represent their base speed (which can be altered through different means) but ive also tried implementing that into the code instead of speed (if spd > 0) to no avail, however.
Is there smth wrong with the order here, or the use of Events?
 

Relic

Member
That on its own looks fine. Try using the debugger- set a breakpoint at the instance_create() line and then check what the value of speed is. I’m guessing it’s greater than 0 then you need to find out why.
 

Yal

🐧 *penguin noises*
GMC Elder
You could also consider using if(point_distance(xprevious,yprevious,x,y) > 1) or something to that effect so that footstep-making is dependent on that you move, rather than how you move.
 
You could also consider using if(point_distance(xprevious,yprevious,x,y) > 1) or something to that effect so that footstep-making is dependent on that you move, rather than how you move.
Hi, yes, exactly what i was trying to reach: that it would just depend on that the character is moving. Thanks!
So it should go to Step, like:

if (point_distance(xprevious,yprevious,x,y) > 1)
{
//create footprints object/effect?
}

So far it didnt produce the effect, (the footprints don't appear at all when moving) are there alternatives, or is my code order wrong here?
Yeah, im aware i need a lot of holding hands here, sorry about that..
 
Care to explain what the problem was and how you solved it? For the sake of future generations...
I used this code i found on the forums on the topic:

moving = 0

Step event:

if moving
{
count += 1;
if (count == 13)
{
count = 0;
bl=instance_create(x,y,obj_footprints)
bl.direction=direction
bl.image_angle=direction
}
}
else
{
count = 0;
}
 
Top