Results 1 to 20 of 146

Thread: Reverse engineering of Wipeout

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Posts
    1,529

    Default

    Wow that looks pretty close to the original without the ugly (but necessary) approximations they had to use!
    You just need to make the ship actually collide with the track.

  2. #2
    Join Date
    Apr 2015
    Location
    France, Paris
    Timezone
    GMT + 1
    Posts
    310

    Default

    Yes it surprisingly does,

    Actually I've been trying a couple of things which didn't work until simply trying the following,

    put the anchor above just like this :

    Disney_Traditions_Goofy_Marionette_4023579.jpg

    So basically my previous code was already good, just had to offset the thing a bit

    For the collision, do you have a rough idea on what formula/concept to look at ? (main idea would be using a home version like for the drag)

    Thanks !!!
    Last edited by aybe; 2nd August 2015 at 01:51 PM.

  3. #3
    Join Date
    Apr 2010
    Posts
    1,529

    Default

    Just use the mesh collider in Unity. No point in complicating that one.

    A more "in-house" way would be detecting which triangle of the track's mesh the ship is sitting on and then calculating the distance from the collider model vertices to the surface of that triangle.

    To detect the triangle you would have to use barycentric coordinates, which are basically "where inside a triangle is a point". https://en.wikipedia.org/wiki/Baryce...rdinate_system
    Look at the calculation for the lambdas in that wikipedia page. That's how you'll find out if a vertex is inside a triangle. This only works in 2D (horizontal plane in our case), so overlapping track portions (bridges, jumps, etc) would need some sort of height condition to ignore the lower track section when the ship went over it.
    Here are some pics from my physics engine doing exactly that:

    http://i.imgur.com/61YFREK.png
    http://i.imgur.com/lML1mmv.png

    A point is inside a triangle when lambda1+lambda2<1 and lambda1>=0 and lambda2>=0
    You make a loop to go through all of the TRACK's surface triangles and detect the one for which the condition above is true and break out of the loop. Then you can repeat that loop every frame or you can judge how much the ship moved and then find the new triangle using the loop, though faster it is more prone to bugs since you can easily misjudge the player's motion and fail to find the triangle correctly.

    To calculate the height of the collider point above the triangle you'll need to calculate the plane equation of that detected triangle. Just look at how to calculate the plane equation from 3 vertices. http://tutorial.math.lamar.edu/Class...sOfPlanes.aspx

    you'll get an equation like this: A*(x)+B*(y)+C*(z)=D
    To get the height of the track in a (px,py) point just solve that equation for track_z= -[D-A*(px)-B*(py)]/C, where px and py are the collision point's coordinates on the horizontal plane (considering z axis as vertical)

    Then your height is (pz-track_z)

    If your height is zero or below, then you have a collision. There are also methods to improve your collision detection, called a posteriori and a priori collision detection.

    This is also useful to align the ship with the track since the A,B,C constants are the components for the plane's (triangle) normal, although that stuff should already be included with the mesh data.
    Last edited by Xpand; 2nd August 2015 at 11:33 AM.

  4. #4
    Join Date
    Apr 2015
    Location
    France, Paris
    Timezone
    GMT + 1
    Posts
    310

    Default

    Yes, I'd rather use OnCollision since it's in Unity and features continuous collision, but ... I've been developing the thing using OnTrigger and now when I go back to OnCollision the ships abruptly looks down ... The old hovering alignment works if I make it 100 times more powerful but then the ship is incredibly stiff

    Anyway, it's obsolete so I must code something new. Been thinking and I guess I know the cause : joint orientation. I'll see if I can make it play nicely with user pitch up/down and the torque with .TargetRotation property. Hopefully if it works then the problem will be fixed at this point.

    If not then, that was my first question regarding the formula for bouncing with OnTrigger, been using this cheap algo but it's really bad:

    Code:
    var yVelocity = Mathf.Abs(transform.InverseTransformDirection(_shipBody.velocity).y);
     _shipBody.AddRelativeForce(_shipBody.transform.up * yVelocity * 2.333f, ForceMode.Impulse);
    Otherwise regarding your tips:
    - barycenter : OK
    - plane : OK
    - triangle search : OK (I guess since I can track the ship's section quite well now)
    - other things : I guess OK

    So I'll definitely dig into this approach if all else fails.

    Coming back to post my results !

    Thanks

  5. #5
    Join Date
    Apr 2010
    Posts
    1,529

    Default

    For the correct bounce you can just invert the velocity component along the triangle's normal (you need to project your velocity vector onto the triangle's normal) (the triangle where the ship hit the ground).


    In terms of projection, if "a" is your velocity vector and "b" your triangle normal, "a1" will be the velocity component along the triangle normal.

    However, to simplify things you can just do what you're doing by just using the vertical component of your velocity (y in your case). Although in steep hills the ship will behave a bit odd.

    You do like: velocity=-velocity*damp_factor. The damp factor is a number between 0 and 1, it defines the bounciness of the ship when it hits. A damp factor of 1 means the ship will bounce back up with the same velocity it hit the ground, 0 means it won't bounce, it'll just hit and stay there.

    If you chooe to go with the projection method you then have to "move back" and rebuild the velocity vector with the new inverted component, you can do that by adding the modified component "a1" to the other component "a2".
    Last edited by Xpand; 2nd August 2015 at 06:16 PM.

  6. #6
    Join Date
    Apr 2015
    Location
    France, Paris
    Timezone
    GMT + 1
    Posts
    310

    Default

    Excellent, going to study that thoroughly

    Thanks

  7. #7
    Join Date
    Apr 2015
    Location
    France, Paris
    Timezone
    GMT + 1
    Posts
    310

    Default

    Hi guys ! It's been a while ... I haven't abandoned the project and plan to get back to work on it ASAP

    How are you guys doing ? Xpand did you get your exam/graduation ?

    Last status was :



    Basically the constraint needs to be wrote again as for the life of me I've never figured out why when switching from Trigger to Collider makes the ship invariably pitch up ... and surprisingly the old hover method is unaffected.

    My plan:

    - get this fixed
    - get some AI and weapons up
    - then the rest
    Last edited by aybe; 24th September 2015 at 01:01 AM.

Posting Permissions

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