Jump to content

Can I detect when an EntityItem is stopped using motionX, Y, Z?


Recommended Posts

to answer your question -- yes you can.  simply test if motionX, motionY, AND motionZ are all == 0.  If 0, the entity is truly stopped.


The long answer...they are adjustment vectors from the current position.


So, if entity is at X = 1.42, and motion X = -0.12, then after the next update tick, the entities position would be X=1.30.  If motionX was +0.12, the entity would be instead at X=1.54.


testing for exact zero for 'stopped' can be misleading...some of those numbers can be very small but non-zero, and the entity would appear stopped for all intents and purposes.  It might be better to test for sqrt(mx*mx+my*my+mz*mz)<=0.002 to see if the entity is just moving really really slow, and might as well be stopped

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.

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.


  • Create New...

Important Information

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