This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-04-21 05:48:51

Noobie600
New Scratcher
Registered: 2012-04-21
Posts: 7

Enemy Following player on x and y

Anyone know an easy way for an enemy to follow a player on the x and y axis?

Offline

 

#2 2012-04-21 09:43:43

pi3
Scratcher
Registered: 2011-12-31
Posts: 500+

Re: Enemy Following player on x and y

I'm not quite sure what you mean. Could you please explain in further detail? I'd love to help!  smile


http://i44.tinypic.com/ofdhc4.jpgThanks FreshStudios!

Offline

 

#3 2012-04-21 09:53:09

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Enemy Following player on x and y

This script will follow the sprite.

when gf clicked
forever
point towards[sprite 1 v]
move (3) steps
If you want the sprite to only move along the x-axis, use this:

when gf clicked
forever
if<((x position)-([x position v] of [sprite 1 v])) < (4)>
change x by (3)
else
if <((x position)-([x position v] of [sprite 1 v])) > (4)>
change x by (-3)
end
end

Last edited by MoreGamesNow (2012-04-21 09:53:28)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#4 2012-04-21 12:34:23

jimmy12384
Scratcher
Registered: 2012-01-18
Posts: 19

Re: Enemy Following player on x and y

it's actually pretty easy, I will try to show you the best way I can because I'm bad at doing the block thing...

When Green flag clicked
    Forever
          glide () seconds to x: x position of sprite ... y: y position of sprite...



() would stand for the number of seconds it will take to get there.

I'm sorry it isn't the best but... there.

Offline

 

#5 2012-04-21 13:38:09

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Enemy Following player on x and y

jimmy12384 wrote:

it's actually pretty easy, I will try to show you the best way I can because I'm bad at doing the block thing...

When Green flag clicked
    Forever
          glide () seconds to x: x position of sprite ... y: y position of sprite...



() would stand for the number of seconds it will take to get there.

I'm sorry it isn't the best but... there.

The problem is that the "glide () seconds to x sad ) y sad )" block can't be interrupted, so if the target-sprite moves, the moving sprite will continue moving to where it used to be, until it finally reaches the old location.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#6 2012-04-22 09:30:19

jimmy12384
Scratcher
Registered: 2012-01-18
Posts: 19

Re: Enemy Following player on x and y

MoreGamesNow wrote:

jimmy12384 wrote:

it's actually pretty easy, I will try to show you the best way I can because I'm bad at doing the block thing...

When Green flag clicked
    Forever
          glide () seconds to x: x position of sprite ... y: y position of sprite...



() would stand for the number of seconds it will take to get there.

I'm sorry it isn't the best but... there.

The problem is that the "glide () seconds to x sad ) y sad )" block can't be interrupted, so if the target-sprite moves, the moving sprite will continue moving to where it used to be, until it finally reaches the old location.

hmm  I guess your right, then I would have to say to go with the above script and do...( I'll try the blocks...)

when gf clicked
forever
    point towards [user v]
    move (3) steps
end

Offline

 

Board footer