Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


Results 1 to 11 of 11

Thread: Collision Detection Kit

  1. #1

    Collision Detection Kit

    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

  2. #2
    rimacy's Avatar
    Registered Schmoozer
    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.

  3. #3
    How 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.

  4. #4
    rimacy's Avatar
    Registered Schmoozer
    Well it aint pretty.
    if ( angle >= 136 || angle <= -136 )
                   bounce right

  5. #5
    oI 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?

  6. #6
    if 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?

  7. #7
    Registered User
    iterate 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

  8. #8
    iterate 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.

  9. #9
    Registered User
    it'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

  10. #10
    it makes sense, bit I cant figure out how to do implement it.

  11. #11
    rimacy's Avatar
    Registered Schmoozer
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About kirupa.com Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012