Page 1 of 1

Collision Detection

PostPosted: Sun Jul 05, 2009 10:50 am
by OmniArts
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)

Re: Collision Detection

PostPosted: Sun Jul 05, 2009 11:44 am
by DST
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.

Re: Collision Detection

PostPosted: Sun Jul 05, 2009 12:31 pm
by OmniArts
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?

Re: Collision Detection

PostPosted: Sun Jul 05, 2009 6:38 pm
by DST
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.