Results 1 to 11 of 11
Thread: Collision Detection Kit
-
April 15th, 2012, 02:28 AM #1881zzz
postsCollision Detection Kit
Hi,
Im playing with the Collision Detection Kit I have it all working but I cant figure out how you would work out the size of the overlap? So I can have it stop when an object hits an object?
I can access the array of points that are colliding but I cant figure out how you would use this to work out the size of the over lap. I want to make a maze type demo that would handle the collisions with the walls etc. using the CDK so that I could curved lines as walls etc.
Any help would be great
-
April 15th, 2012, 02:32 AM #2
Hey there, I love the cdk! I use it in a platformer. I don't use the overlap at all. I just use the collision angle.
-
April 15th, 2012, 03:09 AM #3881zzz
postsHow would you use the collision angle? I looked at that first but the overlapping array seemed like a nice easy way to manage it but I just cant figure out a way to do it.
-
April 15th, 2012, 09:52 AM #4
Well it aint pretty.
Code:if ( angle >= 136 || angle <= -136 ) { bounce right }
-
April 15th, 2012, 11:33 AM #5881zzz
postsoI cant think how I would work that into a decent collision. So for the bounce right example, how would I know how much to move the character back?
-
April 15th, 2012, 12:00 PM #6881zzz
postsif for instance the the char was 4px away from the wall and then it moves 10px so there is a 6 overlap, how do I work this out?
-
April 15th, 2012, 01:39 PM #71,391Registered User
postsiterate by a smaller increment (eg. 1) within a sub-routine backward along the previous vector until the object is not in collision, set it - calc deflection vector
-
April 15th, 2012, 01:59 PM #8881zzz
postsiterate through the overlappinig array? Im a little confused how you mean to go through the array to work out the size of the over lap.
-
April 15th, 2012, 05:02 PM #91,391Registered User
postsit's just a common methodology to prevent/detect tunneling, to break the step apart into smaller sub-steps - where the values are derived from depends on your system - i do not know CDK, so i cannot tell you which properties to gather the information from
-
April 15th, 2012, 05:57 PM #10881zzz
postsit makes sense, bit I cant figure out how to do implement it.
-
April 15th, 2012, 08:30 PM #11
If I want to bounce right for instance
xVel= -.75*(xVel);
this changes the direction and reduces the x velocity
if its bouncing up or down you do the same with yVel.
if you want to prevent tunneling you only preform the collision response with the appropriate xVel. In example a right collision would only respond to a positive x direction that way if(when) you overlap you dont start a left right collision loop.

Reply With Quote

Bookmarks