Collision Detection

Talk about making games.

Collision Detection

Postby OmniArts » Sun Jul 05, 2009 10:50 am

Hi, I'm just currently wondering how I will set up collision detection like this...

As you can see I'd like to have the feet of the player model collide with the bottom of the fence.
I'm hoping I can do this without to much coding work as I'm an artist and I can only code basic things lol :)
But this is part of my job as the level guy so if anyone can explain the process that would be great!

Image

(sorry for the dodgy concept)
User avatar
OmniArts
 
Posts: 134
Joined: Sat May 30, 2009 2:30 am
Location: Sydney
Score: 16 Give a positive score

Re: Collision Detection

Postby DST » Sun Jul 05, 2009 11:44 am

In this case, it seems simpler to just use the y position of the player.

Just find the bottom y of the fence and tell the player to stay below that.
if fence doesn't move vertically, use the actual y of the fence bottom.
if fence can move, use fencey=fence.y+(fence.height/2);
Whatever the number is, i'll call it fencey for this example:
then subtract the player height: fencey-=(player.height/2);


player>draw actor>
Code: Select all
if(y<fencey){
y=fency;}




If for some reason your fence moves all over or changes shape in some areas and you absolutely must have a collision, just make a FILLED REGION actor and put it at players feet, to the size you want, then in the actor panel for the filled region actor, set parent to player.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Collision Detection

Postby OmniArts » Sun Jul 05, 2009 12:31 pm

Thanks for the quick reply. The Fence moves around a bit, x,y diagonal. I think i'll need to use collision.
I have created the filled region and set the parent to the player. Sorry if im missing something here but then what?
User avatar
OmniArts
 
Posts: 134
Joined: Sat May 30, 2009 2:30 am
Location: Sydney
Score: 16 Give a positive score

Re: Collision Detection

Postby DST » Sun Jul 05, 2009 6:38 pm

collider>collision>bottom side>fence>
Code: Select all
If(player.yvelocity<0){
player.yvelocity=0;
}


You will need to do something like that, because you cannot transfer the force of a physical response from a child to parent.
Block the player from moving into the fence area.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron