# [Solved] [1.19] Heading between two objects

## Recommended Posts

I am struggling to figure out how to calculate the heading for a projectile, i.e. in .shoot or setArrowHeading, between two entities.

For example, if I have entities A and B, and I want a projectile to fire from A to B but want to ignore the facing, I had thought it would have been simple enough to do ...

x = target.getX() - firer.getX()

... for x, y and z. This seems to fire it in weird and wonderful directions.

After much Googling, it is still not clear to me what I should be passing into shoot for pX, pY and pZ.

Any tips or suggestions would be really appreciated.

Edited by Scytale
##### Share on other sites

if the idea requires mathematical knowledge that you do not have (working with angles) and programming skills you do not have (skipping math and finding a way to reuse existing projectile logic), why are you still working on this mod? surely you can come up with a mod idea without impassable barriers.

##### Share on other sites

20 minutes ago, MFMods said:

if the idea requires mathematical knowledge that you do not have ...

My experience to date, in this forum, has been some wonderful friendly people who were willing to help and provide some kind assistance.

##### Share on other sites

• 2 weeks later...

Aside from the passive aggressive response, there was a tip buried there ... mathematical knowledge.

For closure ...

The heading between two entities is a rotation around the x and y axis - x for horizonal rotation and y for vertical. Thus simple trigonometry is used to calculate the angle of rotation between the x,y coordinates of the two entities.

##### Share on other sites

• Scytale changed the title to [Solved] [1.19] Heading between two objects

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

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

### Announcements

×

• #### Activity

×
• Create New...