Page 1 of 1

detecting collision points

PostPosted: Mon Nov 19, 2007 5:28 pm
by ayotot
Hi all
(maybe I should've posted this in advanced topics??? :wink: )

Is there a variable which defines the collision side with which the player collides?
see the screenie and realize what I mean:
turning goomba.jpg


now, when the goomba goes round the loop, it should turn.
I got the animation, I know about animpos and stuff like that.
spinninggoomba.gif
spinninggoomba.gif (55.05 KiB) Viewed 720 times



Please, could somebody give me a script example or a turtorial?
Help would be appriceated and awarded with 1 point.

Re: detecting collision points

PostPosted: Mon Nov 19, 2007 7:26 pm
by pixelpoop
You can determine the side of collision but I don't think it is accurate enough for what you want to do. I think it only does left, right, top and bottom.

What I would do is make each circular path its own graphic or make an invisible actor in the center of the loop. Then you can calculate the direction from the center to the mushroom guy and use that angle to assign the proper animation to the mushroom. This can get weird looking though if your loops are ovals rather then circles.

It would be something like:
animpos=direction(center.x, center.y, mushroom.x, mushroom.y)/20;

The 20 is if your animation has 18 frames. (360 possible degrees, divided by the total animation positions(18 is this case) is equal to 20.)
Also since zero degrees is directly right, you have to start your animation with the characters feet facing right.(i think)

Also you could do this with ovals, you would just have to set up multiple centers for each loop and that would get tricky fast.

Re: detecting collision points

PostPosted: Tue Nov 20, 2007 5:00 am
by kyensoftware
Just set it so if it hits left increase animpos to the left(clockwise??)direction.
P.S. Im BAAAAAAACK! I never had a virus, just a crappy mouse. Im a dumbass :roll: :cry: :wink: :mrgreen: