XNA Creators Club Online
Page 1 of 1 (7 items)
Sort Posts: Previous Next

Help on Camera/Player Collision Detection and Sliding

Last post 10/07/2009 12:39 by HRuivo. 6 replies.
  • 03/07/2009 21:13

    Help on Camera/Player Collision Detection and Sliding

    Hi all,

    I have begun for about near 2 weeks searching and working on a camera or player collision detection and sliding with world's walls, and I'm stuck on the sliding logic.

    What I have:
    all the blue points.
    all the green lines.

    What I need:
    the red point.




    What I think I have to do is to increment the coord of the intersection point with the size of the line intersection point to red dot, but I don't know how to do that.
    I'm hoping if you could help me with this math prob, after this I just have to add gravity which is easy.

    HRuivo.
  • 03/07/2009 22:28 In reply to

    Re: Help on Camera/Player Collision Detection and Sliding

    1) calculate the distance traveled along the wall normal.
    2) if the distance traveled is longer than the distance to the wall, add the wall normal times the excess to push the point out.


    Correction = PenetrationDepth * WallNormal

    If we assume that the wall is defined by "Point dot WallNormal plus D equals 0" then you find penetration as:

    PenetrationDepth = NewPoint dot WallNormal - D

    Note that OldPoint isn't needed at all; the point you want to find can be found simply using NewPoint.

    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 07/07/2009 12:42 In reply to

    Re: Help on Camera/Player Collision Detection and Sliding

    Thank you for the reply jwatte.

    But I'm not understanding it very well, can you explain yourself better?

    By the way can't I use the distance I got from the triangle's edges to determine the red coord?

    HRuivo.
  • 07/07/2009 16:42 In reply to

    Re: Help on Camera/Player Collision Detection and Sliding

    How is the wall expressed? Is it expressed as a plane, or as something else? If something else, do you know how to turn that into a plane equation?
    Once you have the plane equation, what about the math in my post do you find unclear or hard to turn into code?

    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 09/07/2009 22:05 In reply to

    Re: Help on Camera/Player Collision Detection and Sliding

    Finally I get some time to post here...

    I just use a ray to see where I intersect with the bounding box. But really wanted to know how to express a plane using the model's vertices.
    About the math you posted, what do you mean by Correction? the desired camera position? And what about D?
  • 10/07/2009 4:32 In reply to

    Re: Help on Camera/Player Collision Detection and Sliding

    I'll think you need to learn 3D linear algebra maths before you can actually develop a collision/simulation system.
    This book is pretty good. It assumes you know regular multiplication, division and equation solving, though.
    If you don't want to do it yourself, look into something ready-made, like JibLibX.

    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 10/07/2009 12:39 In reply to

    Re: Help on Camera/Player Collision Detection and Sliding

    Thanks for the book reference I will take a look at it, cus I really want to make my own collision system.
    I already used JibLibX to make it, but its a bit buggy, maybe with some enfort I could make it "perfect" but the 'old' way is far better.

    Thanks for the help.

    HRuivo.

Page 1 of 1 (7 items) Previous Next