following the target

Non-platform specific questions.

following the target

Postby hobgoblin » Sun Feb 22, 2004 9:39 pm

on my game, the bad guys have to follow the target and smack him
(i tried the tutorial but i didnt understand...)

i tried...
(in the badguy)

draw actor
add action
conditional action

conditional action
expression 1:
y
expression2:
target.y

then i should go to script and type "y=y+5"

what am i doing wrong
hobgoblin
 
Posts: 97
Joined: Sat Feb 21, 2004 5:10 pm
Location: BEHIND YOU!!!
Score: 0 Give a positive score

Postby hobgoblin » Sun Feb 22, 2004 9:42 pm

and by the way!

i'm gonna put a "bad guy factory" to produce more badguys!

but the factory produces only one and stop!

how can i make it produce more?
hobgoblin
 
Posts: 97
Joined: Sat Feb 21, 2004 5:10 pm
Location: BEHIND YOU!!!
Score: 0 Give a positive score

Postby makslane » Mon Feb 23, 2004 5:36 pm

Try this:

On Draw Actor, add a Script Editor action:

if(target.y > y) y = y + 5;
else if(target.y < y) y = y - 5;

if(target.x > x) x = x + 5;
else if(target.x < x) x = x - 5;


Factory:

On Create Actor event:

1) Add a "Create Timer" action
2) choose new timer

Name: any name
Time: 12
Type: Periodic
Repeat: Specify quantity
Count: 100 (to create 100 bad guys)

3) Ok, Add, Immediate Action


On Timer event:

1) choose your timer
2) Add "Create Actor" action

Actor: bad guy
Animation: (set if any)
Parent: no parent
Path: no path
Initial Position: 0, 0
Relative to creator: yes

3) Add, Immediate Action


To put your bad guys on a random location:

On Bad Guy Create Actor event:

x = rand(view.width) + view.x;
y = rand(view.height) + view.y;
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby hobgoblin » Tue Feb 24, 2004 1:17 am

makslane wrote:Try this:

On Draw Actor, add a Script Editor action:

if(target.y > y) y = y + 5;
else if(target.y < y) y = y - 5;

if(target.x > x) x = x + 5;
else if(target.x < x) x = x - 5;




doesn't work

are you sure i don't have to declare the goodguy as the target for the badguy before i white this thing?
(i don't know how to do it =P )
hobgoblin
 
Posts: 97
Joined: Sat Feb 21, 2004 5:10 pm
Location: BEHIND YOU!!!
Score: 0 Give a positive score

Postby hobgoblin » Tue Feb 24, 2004 1:55 am

To put your bad guys on a random location:

On Bad Guy Create Actor event:

x = rand(view.width) + view.x;
y = rand(view.height) + view.y;


ok, but i don't want then to be created on random
i want to create them out of the screem and make them walk slowly to the character
__________

i'm noob =P
__________
hobgoblin
 
Posts: 97
Joined: Sat Feb 21, 2004 5:10 pm
Location: BEHIND YOU!!!
Score: 0 Give a positive score

Postby makslane » Tue Feb 24, 2004 4:53 pm

hobgoblin wrote:
doesn't work

are you sure i don't have to declare the goodguy as the target for the badguy before i white this thing?
(i don't know how to do it =P )



This works?

if(goodguy.y > y) y = y + 5;
else if(goodguy.y < y) y = y - 5;

if(goodguy.x > x) x = x + 5;
else if(goodguy.x < x) x = x - 5;
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby hobgoblin » Tue Feb 24, 2004 8:05 pm

makslane wrote:
hobgoblin wrote:
doesn't work

are you sure i don't have to declare the goodguy as the target for the badguy before i white this thing?
(i don't know how to do it =P )



This works?

if(goodguy.y > y) y = y + 5;
else if(goodguy.y < y) y = y - 5;

if(goodguy.x > x) x = x + 5;
else if(goodguy.x < x) x = x - 5;


that is better...ty!
__________

i'm noob =P
__________
hobgoblin
 
Posts: 97
Joined: Sat Feb 21, 2004 5:10 pm
Location: BEHIND YOU!!!
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest