Jump to content



Recommended Posts

I am creating a game to test, there is no scenario, obstacles and nothing.
My question is that I'm trying to get an object to move to a certain coordinate I want.

Example, I want to move a ball to the coordinates of DestX, DestY and DestZ.

I've looked a lot for pathfinding, but I can not find anything that solves my problem. I just think moves executed by the keyboard arrows, I need to set the coordinates and this object should get there

Link to comment
Share on other sites

  • 4 years later...

To solve this issue, we need to understand a little we know:
where is the front and back side of the object;
the current position of the object;
the angle by which the object is rotated.
the distance the object must cover.
Additional data needed. Then we introduce the concept of a quarter. It's no secret that in a two-dimensional Cartesian coordinate system there are 4 quarters, from 1 to 4 respectively. In each quarter, the axes have different signs.

Link to comment
Share on other sites

Once you explain everything to yourself, you can proceed directly to the script. As input, we take the Transform of the original object after the rotation and the Transform of the empty, to which we will subsequently move. The empty initially has the coordinates of the object. Next, we determine the quarter in which the front of the object is located. Since the trigonometric circle is limited from 0 to 360 degrees, this is not difficult. Having determined a quarter, we calculate the angles of inclination for each coordinate. Then we check that our angles have the correct sign. After that, we send the tilt angles to the final formula for calculating the coordinates. And finally, we set new coordinates to the empty, to which we will interpolate.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...