Jump to content

Recommended Posts

Posted (edited)

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
Posted

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.

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

  • 2 weeks later...
Posted

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.

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

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

×   Pasted as rich text.   Restore formatting

  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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.