Jump to content

Entity Movement problems (moving a entity to certain cords by adding velocity)


Recommended Posts

Posted

Hi, I'm trying to make an item where when you right click on something (block or entity), it makes you jump to it.  I have all the code to get the difference in cords from the target to the player, but I need to know how much velocity to add to the player to get them to land at those cords.  It would also help if I could find the code that moves the entity (like gravity).

 

Edit:  Preferably, the launch angle would be 45 degrees.

 

Edit 2:  I could solve this with the Equations of Gravity if I new the units of an entity's motion and how minecraft's gravity works.

Posted

This is an example of where I would suggest using "brute force" rather than trying to be mathematically correct.  Doing reverse trajectory calculations can be tricky in normal physics and Minecraft physics is even weirder.

 

What I would do is to simply experiment and record the velocity (and angle if you're changing that too) necessary to hit each distance.  Then once you have all the velocities known for different distances, then in your code just create an array with those values and look it up.  Understand what I mean?

 

I guarantee that that will be much faster to code than to try to figure out all the math for a closed form calculation.  No trigonometry required!

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.