Jump to content

How to calculate motion from distance and height


Colened

Recommended Posts

I want an entity to draw a trajectory and move 5 blocks horizontally and 4 blocks vertically in a direction where a player is looking in the end.

I have tried below, but the entity moved further and higher.

Vector3d vector = player.getLookVec().normalize().mul(5, 1, 5);
entity.setMotion(vector.x, 4, vector.z);

How can I derive the motion from desired distance and height?

Link to comment
Share on other sites

There's a difference between velocity and distance. First, you normalize the look vector. This means that the vector will be anywhere from 0-1. Also, when you multiply it by 5, you are moving 5x more in the direction you were looking. Also, the motion upward will be 4. This is the velocity of the object (which is the distance per unit of time). So, based on the time unit used by Minecraft, in the first time unit, the user will move 5x the normalized look vector and 4 upwards. Their motion will continue in that direction for a parabolic curve of some kind depending on the motion calculated.

So, basically, just do physics.

Link to comment
Share on other sites

29 minutes ago, Colened said:

Do you know how the velocity changes over time?

That's physics once again. You should really look over Newton's Laws of Motion to understand that. As for Minecraft's specific case, I've never looked into it.

31 minutes ago, Colened said:

I found this table on the wiki but I do not get how to interpret those values.

Again physics. It even gives you the calculations. A player has a velocity of 3.92 blocks per every in-game tick. Their acceleration is 0.08 blocks per every in-game tick squared. This forum is not really a physics course. You should probably look up actual velocity, distance, and acceleration formulas, plug the values in, and adjust to get the values you want.

Link to comment
Share on other sites

8 hours ago, ChampionAsh5357 said:

You should probably look up actual velocity, distance, and acceleration formulas, plug the values in, and adjust to get the values you want.

I do know this is related to projectile motion.

With trials and errors, I found that a vector of length 1.1 and an angle of 50 degrees almost result in what I want but when I plug those values in v^2 * sin(2 * θ) / g (as noted here) where v = 1.1, θ = 50 / 180 * 3.14 and g = 0.08, its result is larger than how much an entity moves in the game. I wanted to know if there is a specific equation that Minecraft uses or what are the values that Minecraft uses in the projectile motion not to be lectured for physics.

Link to comment
Share on other sites

2 hours ago, Colened said:

or what are the values that Minecraft uses in the projectile motion not to be lectured for physics

Apologies, not trying to lecture you. I just assume that the person I'm talking to only knows enough information in Java and not anything else. Only reason I mention it is that it's how any game calculates physics.

 

If I remember correctly, the entity's motion in the x and z every tick is multiplied by 0.91 and the slipperiness of the block underneath if the entity is on the ground. For the y direction, it's motion should be the y motion minus the effect of gravity (by default 0.08) and multiplied by 0.98f.

Link to comment
Share on other sites

Due to air resistance*

I hate that it's baked in as a hardcoded value and not labeled in any way, but that's where the value comes from.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

5 hours ago, ChampionAsh5357 said:

Apologies, not trying to lecture you.

I also apologize if I sounded rude.

5 hours ago, ChampionAsh5357 said:

If I remember correctly, the entity's motion in the x and z every tick is multiplied by 0.91 and the slipperiness of the block underneath if the entity is on the ground. For the y direction, it's motion should be the y motion minus the effect of gravity (by default 0.08) and multiplied by 0.98f.

5 hours ago, Draco18s said:

Due to air resistance*

Thank both of you. I guess I either have to try to come up with a quite complicated equation or just stick with trials and errors.

Link to comment
Share on other sites

  • 1 year later...
On 10/1/2020 at 6:01 AM, ChampionAsh5357 said:

If I remember correctly, the entity's motion in the x and z every tick is multiplied by 0.91 and the slipperiness of the block underneath if the entity is on the ground. For the y direction, it's motion should be the y motion minus the effect of gravity (by default 0.08) and multiplied by 0.98f.

Yeah, it's exactly this. I've used this in many of my projects, and it's working perfectly to change gravity strength and air resistance accurately.

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Akun Pro Kamboja adalah pilihan terbaik bagi Anda yang mencari pengalaman bermain slot Maxwin dengan transaksi mudah menggunakan Bank Lampung. Berikut adalah beberapa alasan mengapa Anda harus memilih Akun Pro Kamboja: Slot Maxwin Terbaik Kami menyajikan koleksi slot Maxwin terbaik yang menawarkan kesenangan bermain dan peluang kemenangan besar. Dengan fitur-fitur unggulan dan tema-tema menarik, setiap putaran permainan akan memberikan Anda pengalaman yang tak terlupakan. Transaksi Mudah dengan Bank Lampung Kami menyediakan layanan transaksi mudah melalui Bank Lampung untuk kenyamanan dan keamanan Anda. Dengan proses yang cepat dan efisien, Anda dapat melakukan deposit dan penarikan dana dengan lancar dan tanpa hambatan. Anti Rungkat Akun Pro Kamboja memberikan jaminan "anti rungkat" kepada para pemainnya. Dengan fitur ini, Anda dapat merasakan sensasi bermain dengan percaya diri, karena kami memastikan pengalaman bermain yang adil dan menyenangkan bagi semua pemain.  
    • BINGO188: Destinasi Terbaik untuk Pengalaman Slot yang Terjamin Selamat datang di BINGO188, tempat terbaik bagi para pecinta slot yang mencari pengalaman bermain yang terjamin dan penuh kemenangan. Di sini, kami menawarkan fitur unggulan yang dirancang untuk memastikan kepuasan dan keamanan Anda. Situs Slot Garansi Kekalahan 100 Kami memahami bahwa kadang-kadang kekalahan adalah bagian dari permainan. Namun, di BINGO188, kami memberikan jaminan keamanan dengan fitur garansi kekalahan 100. Jika Anda mengalami kekalahan, kami akan mengembalikan saldo Anda secara penuh. Kemenangan atau uang kembali, kami memastikan Anda tetap merasa aman dan nyaman. Bebas IP Tanpa TO Nikmati kebebasan bermain tanpa batasan IP dan tanpa harus khawatir tentang TO (Turn Over) di BINGO188. Fokuslah pada permainan Anda dan rasakan sensasi kemenangan tanpa hambatan. Server Thailand Paling Gacor Hari Ini Bergabunglah dengan server terbaik di Thailand hanya di BINGO188! Dengan tingkat kemenangan yang tinggi dan pengalaman bermain yang lancar, server kami dijamin akan memberikan Anda pengalaman slot yang tak tertandingi. Kesimpulan BINGO188 adalah pilihan terbaik bagi Anda yang menginginkan pengalaman bermain slot yang terjamin dan penuh kemenangan. Dengan fitur situs slot garansi kekalahan 100, bebas IP tanpa TO, dan server Thailand paling gacor hari ini, kami siap memberikan Anda pengalaman bermain yang aman, nyaman, dan menguntungkan. Bergabunglah sekarang dan mulailah petualangan slot Anda di BINGO188!
    • Mengapa Memilih AlibabaSlot? AlibabaSlot adalah pilihan terbaik bagi Anda yang mencari slot gacor dari Pgsoft dengan transaksi mudah menggunakan Bank Panin. Berikut adalah beberapa alasan mengapa Anda harus memilih AlibabaSlot: Slot Gacor dari Pgsoft Kami menyajikan koleksi slot gacor terbaik dari Pgsoft. Dengan fitur-fitur unggulan dan peluang kemenangan yang tinggi, setiap putaran permainan akan memberikan Anda kesenangan dan keuntungan yang maksimal. Transaksi Mudah dengan Bank Panin Kami menyediakan layanan transaksi mudah melalui Bank Panin untuk kenyamanan dan keamanan Anda. Dengan proses yang cepat dan efisien, Anda dapat melakukan deposit dan penarikan dana dengan lancar dan tanpa masalah.  
    • Delete the jei-server.toml file in your config folder and test it again
    • java.util.ConcurrentModificationException at java.base/java.util.HashMap.computeIfAbsent(Unknown Source) at Genesis//com.moonsworth.lunar. ... Looks like an issue with the Launcher - Make a test with another Launcher like MultiMC, AT Launcher or Technic Launcher or try the original one
  • Topics

×
×
  • Create New...

Important Information

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