How to check if an entity is moving in any direction

Started by The Ult1mate Guy on

Topic category: Help with MCreator software

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to check if an entity is moving in any direction

I am aware of the velocity XYZ pieces, however I have no idea how to check if one or more of them are >0, seeing as there's no "and/or" logic type. Any help is appreciated!

 "and/or" There is in the…
Sat, 11/28/2020 - 10:22

 "and/or"

There is in the logic section.

Also, I suggest getting common velocity vectors length using Pythagorean theorem extended for 3 dimensions.

I suggest you check our tutorials collection playlist on our YouTube channel which contains many examples and tutorials that can help you get started with MCreator: https://www.youtube.com/playlist?list=PLAeL-oIFIEngE6jRgFYeFMfuj8WQsO3Ei

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
So after tripe-checking I…
Sat, 11/28/2020 - 17:15

So after tripe-checking I can't find the "and/or" statement. I found "and" and "or," but not "and/or."

Unfortunately I have no idea what you mean by "getting common velocity vectors length using Pythagorean theorem extended for 3 dimensions."

And I don't immediately see anything in the playlist that would help figure out if a mob is walking.

Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You use both blocks together…
Sat, 11/28/2020 - 17:51

You use both blocks together.

IF(( x velocity > 0 )AND (y velocity > 0) AND (y velocity > 0)

Put multiple of the blocks together.

 

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The issue with that is then…
Sat, 11/28/2020 - 19:40

The issue with that is then the game checks if all velocities are >0, as opposed to at least one; it looks for the entity moving diagonally and jumping.

Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Then change the AND to OR…
Sat, 11/28/2020 - 20:44

Then change the AND to OR.

IF(( x velocity > 0 )OR (y velocity > 0)  OR (z velocity > 0)

//do stuff

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Well now I made a "and/or"…
Sat, 11/28/2020 - 21:03

Well now I made a "and/or" by literally mixing the "and" and "or" boxes, and it almost works

Now I just need to figure out why adding a do/while loop breaks the game...

Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Don't use a loop if you want…
Sat, 11/28/2020 - 21:17

Don't use a loop if you want to check if the entity is moving every second.

If the you are trying to check if the player is moving use the global trigger "on player tick update".

Then remove the loop and use an if statement.

You won't need the loop statement because it is being called every second (tick but let's not get technical).

If it is a custom entity use the entity trigger on entity tick update doing the same steps as above.

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Right, I got that I almost…
Sat, 11/28/2020 - 21:23

Right, I got that

I almost got this working now

it seems to only activate once the entity is stopped now, as opposed to when it moves, in other words the opposite of what I'm looking for

But good progress!

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I think I have a guess as to…
Sat, 11/28/2020 - 21:30

I think I have a guess as to what is the issue, just need to figure out how to fix it

Since it's getting called every tick, the animation resets and looks like it's not playing, but when it stops (and thus the if is no longer true), it stops resetting and plays the animation properly

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yep, that's definitely it. I…
Sat, 11/28/2020 - 21:35

Yep, that's definitely it. I swapped the do from playing an animation to dropping an item and the entity started spewing them anytime it moved.

So now I need to figure out how to prevent it from being constantly called if an animation is already playing

Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if entity is moving AND…
Sat, 11/28/2020 - 21:52

if entity is moving AND logic nbt tag "animation_active" = false{

set logic nbt tag "animation_active" to true.

play animation

if NOT entity is moving {

   set logic nbt tag "animation_active" to false

}

 

The "moving" part is the code I showed you before that I didn't want to write again.

You might need to make a timer to loop your animation while walking.

Never used GeckoLib but the should loop : true box should work/

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yeah, that's worked so far,…
Sat, 11/28/2020 - 22:10

Yeah, that's worked so far, now all I need to do is figure out how to stop the animation without playing a new one.

Currently the mob performs the animation and it loops until I "place click" (not hit) the mob, causing it to activate another procedure and play a non-looping animation (which I intend to be part of the final product) which cancels the looped one. Forcing another animation to play if entity moving is false prevents the other procedure from working.

A timer could be useful, but I'm not sure how to do so.

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Might be on to something, I…
Sat, 11/28/2020 - 22:55

Might be on to something, I'll update in a bit