Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

[GM7]Automatic running


Recommended Posts

Here is my code for walking

if global.action=2
{suck=0
sprite_index=Kirby_Walk
if xdir=1
{hspeed=2}
else
{hspeed=-2}
}[/CODE]

I changed it to this

[CODE]if global.action=2
{suck=0
sprite_index=Kirby_Walk
if xdir=1
{hspeed=2
alarm[1] = 20}
else
{hspeed=-2
alarm[1] = 20}
}[/CODE]

In alarm 1 I put

[CODE]suck=0
sprite_index=Kirby_Run
if xdir=1
{hspeed=5}
else
{hspeed=-5}
[/CODE]

Didn't work.... What am I doing wrong? What I want is if my "player" walks for a certain amount of time he starts running.

Link to comment
Share on other sites

Hmm...maybe it's because the 'hspeed = 2' is overriding what's happening when the alarm is triggered. Try making it conditional, like so...

boolean running = false

if global.action=2
{suck=0
sprite_index=Kirby_Walk
if xdir=1
    {if running = false
{hspeed=2}
alarm[1] = 20}
else
     {if running = false
{hspeed=-2}
alarm[1] = 20}
}

suck=0
sprite_index=Kirby_Run
    running = true
if xdir=1
{hspeed=5}
else
{hspeed=-5}

...or something along those lines. Hope that helps; I'm not too knowledgeable about GM syntax.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...