Collide Actor

Talk about making games.

Collide Actor

Postby laddsa » Tue Aug 08, 2006 9:15 pm

Hi, if I have several actors moving around the screen randomly, and one stationery actor (called 'wall'), how can I find out which actor is colliding with the 'wall' actor?

Thanks in advance!

Laddsa
laddsa
 
Posts: 22
Joined: Sun Jul 24, 2005 10:18 am
Score: 0 Give a positive score

Postby Game A Gogo » Tue Aug 08, 2006 9:33 pm

are you using clones?
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby laddsa » Tue Aug 08, 2006 9:38 pm

Hi Game a Gogo,

I haven't used any clone actors, just several individual actors (and the wall actor).

Thanks,

Laddsa
laddsa
 
Posts: 22
Joined: Sun Jul 24, 2005 10:18 am
Score: 0 Give a positive score

Postby Game A Gogo » Tue Aug 08, 2006 9:53 pm

well, in that case, you will have to do a collision check for every actor or using the "getactorincollision" something like that
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby makslane » Tue Aug 08, 2006 9:58 pm

Use the 'collide' actor in the script to get the name of current collide actor.
In a collision event, you can get the name of collide actor with:

Code: Select all
collide.name
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Game A Gogo » Tue Aug 08, 2006 10:03 pm

makslane wrote:Use the 'collide' actor in the script to get the name of current collide actor.
In a collision event, you can get the name of collide actor with:

Code: Select all
collide.name

cool, that will come in handy!

what dos it dos when it collide whit multiple actor?
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby laddsa » Tue Aug 08, 2006 10:17 pm

Thanks chaps, i'lll give that a go!

laddsa
laddsa
 
Posts: 22
Joined: Sun Jul 24, 2005 10:18 am
Score: 0 Give a positive score

Postby makslane » Tue Aug 08, 2006 11:59 pm

Game a Gogo wrote:what dos it dos when it collide whit multiple actor?


You receive one collision event for each actor.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby laddsa » Wed Aug 09, 2006 10:04 pm

That works fine and I am able to determine the actor that has collided with the wall. How do I use this information to move this actor? I have tried putting the 'collide.name' value into a string variable called 'col_actor' to identify the collide actor, and use it to move that actor, i.e.,

col_actor.x=col_actor.x-1;

But this doesn't seem to work. Is there another way I can achieve this?

Many thanks,

Laddsa
laddsa
 
Posts: 22
Joined: Sun Jul 24, 2005 10:18 am
Score: 0 Give a positive score

Postby makslane » Wed Aug 09, 2006 10:40 pm

Use the MoveTo action relative to the collide actor:

Code: Select all
MoveTo(collide.clonename, -1, 0, 10, collide.clonename);


Will move the collide actor to left 1 pixel.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby laddsa » Thu Aug 10, 2006 5:47 pm

That works great! Thanks Makslane!

Laddsa
laddsa
 
Posts: 22
Joined: Sun Jul 24, 2005 10:18 am
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron