• 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!

How i can create NPC Movement like Pokemon Red?

S

srchaos

Guest
Hi, i'm actually creating a Platform game and i would like help with this : (

From my project:



Thanks for view
 
M

Mann_mit_Hut

Guest
Set a random alarm every few seconds that set a new target locarion and move the npc towards it in the step event. When he gehts there distance is 0 and he stops :)
 
S

srchaos

Guest
Set a random alarm every few seconds that set a new target locarion and move the npc towards it in the step event. When he gehts there distance is 0 and he stops :)
Nice, and how i can do the animation?
 
M

Mann_mit_Hut

Guest
animation? you mean movement? with something like:
if x < targetx { x = x + walkspeed }
if x > targetx { x = x - walkspeed }
 
S

srchaos

Guest
animation? you mean movement? with something like:
if x < targetx { x = x + walkspeed }
if x > targetx { x = x - walkspeed }
I mean, when NPC isn't move, have the sprite idle... and when NPC start move change it for the sprite walking
 
J

JVGameDev

Guest
animation? you mean movement? with something like:
if x < targetx { x = x + walkspeed }
if x > targetx { x = x - walkspeed }
I think he means how does me make it where the Npc has a walk animation while walking?
 
M

Mann_mit_Hut

Guest
the video in the first thread shows a walking animation from your project and many other animations, so where is the problem exactly with this type of anymation?
 
S

srchaos

Guest
I share how i make the player animation:

Code:
///Animation

 if (intMove!=0) image_xscale = intMove;
    if (place_meeting(x,y+1,obj_block01))
    {
    if (intMove!=0) sprite_index = spr_player_move
    
    else sprite_index = spr_cplayer;
 }

IntMove = Keyboard_check left and right, so... the problem is how i can know when the npc moves to left or right?
 
S

srchaos

Guest
the video in the first thread shows a walking animation from your project and many other animations, so where is the problem exactly with this type of anymation?
I share how i make the player animation:

Code:
///Animation

if (intMove!=0) image_xscale = intMove;
if (place_meeting(x,y+1,obj_block01))
{
if (intMove!=0) sprite_index = spr_player_move

else sprite_index = spr_player;
}

IntMove = Keyboard_check left and right, so... the problem is how i can know when the npc moves to left or right?
 
M

Mann_mit_Hut

Guest
just combine your intMove technique by adding something like this to my code above:
if x < targetx { intMove=1 }
if x > targetx { intMove=-1 }
if abs(x-targetx) <= walkspeed { x=targetx; intMove=0 }
 
Top