0
\$\begingroup\$

I have an algorithme to find.

I have a player in a 3D space on a random planet. My goal is to have an oriented gravity toward my planet. And when I jump: Find the right normal direction.

enter image description here

BUT I can't just get the normal of collision, here is why: enter image description here

As you can see, the gravity must NOT be depending on the Normals collision, but must depend on this gravity point, line or quad I place in the Level Design

(see the 2 cube at the bottom of the planet, the jump of the player must NOT depend on the normal of collision (orange arrow), but must depend on the red arrow)

I have to find out depending on the position of the player, if the gravity will depend on the closest Gravity Point attractor, OR the closest line, OR the quad's normal direction. Here a real screenShot exemple: enter image description here

I want this algorithm to be dynamic enough to be able to place points, lines or quad in the LevelDesign as I want. This algorithm will be called at each frame when the player is in the air.

And here an exemple of the most complexe shape I would like to manage:

enter image description here Here I have a white point alone, a cyan line, and 2 quad (or 4 triangles)

\$\endgroup\$
  • 2
    \$\begingroup\$ Are you sure you want to attract to the lines, and not to the convex hull of the attractor points? Or, more generally, do you just want a method to model gravitational attraction to an irregularly shaped body, even if those solutions don't use placed attractor points per se? \$\endgroup\$ – DMGregory Feb 13 '19 at 16:16
  • \$\begingroup\$ I edited my question to describe precisely what I want, Thanks \$\endgroup\$ – Ugo Hed Feb 14 '19 at 20:00
0
\$\begingroup\$

Ok, Here is my first approach:

  • loop through all attractor points, and save the closest one from the player.

  • then, loop through all lines, and find for each line its nearest point from the player, with an algo: enter image description here

At the end, select the closest point found.

  • Finaly, if I have quad, get the closest point from the quad to the player

And when everything is done, find the nearest point found.

I'm afraid it's too much computation, if someone has a better approach I'm a taker.

EDIT: computation done and optimized, result in video (source in description of the video) https://youtu.be/bTRlOGiAM7w and here the process of LD creation: https://youtu.be/Q-Ivelnkew8

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.