How to check if an entity is moving in any direction

Started by The Ult1mate Guy on Sat, 11/28/2020 - 05:15

Topic category: Help with MCreator software

Last seen on 00:50, 6. Dec 2020
Joined Jan 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How to check if an entity is moving in any direction
Sat, 11/28/2020 - 05:15

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!

Last seen on 16:49, 23. Jan 2021
Joined Apr 2010
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
 "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

Last seen on 00:50, 6. Dec 2020
Joined Jan 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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.

Last seen on 20:21, 22. Jan 2021
Joined Nov 2018
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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.

 

Last seen on 00:50, 6. Dec 2020
Joined Jan 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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.

Last seen on 20:21, 22. Jan 2021
Joined Nov 2018
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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

Last seen on 00:50, 6. Dec 2020
Joined Jan 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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...

Last seen on 20:21, 22. Jan 2021
Joined Nov 2018
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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.

Last seen on 00:50, 6. Dec 2020
Joined Jan 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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!

Last seen on 00:50, 6. Dec 2020
Joined Jan 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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

Last seen on 00:50, 6. Dec 2020
Joined Jan 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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

Last seen on 20:21, 22. Jan 2021
Joined Nov 2018
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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/

Last seen on 00:50, 6. Dec 2020
Joined Jan 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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.

Last seen on 00:50, 6. Dec 2020
Joined Jan 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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

Last seen on 00:50, 6. Dec 2020
Joined Jan 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
IT WORKS!
Sat, 11/28/2020 - 23:04

IT WORKS!