How to make a custom entity do lunge/charge attacks at you like vexes/phantoms?

Started by Shadowfemb on

Topic category: Help with MCreator software

Last seen on 01:11, 28. Jan 2024
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make a custom entity do lunge/charge attacks at you like vexes/phantoms?

what the tittle says, im making a flying mob that acts similar to a vex but without going thru walls, how can i make it attack like one?

Last seen on 20:37, 26. Jul 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You'd need to use the …
Sun, 01/28/2024 - 17:56

You'd need to use the 'override motion delta' block to add velocity to the entity. You'd also need to do some math to get the x/y/z components of a vector to the nearest player. (So you know how much velocity to add.) If you know how to do 2D vectors, (that is, get the x and z components of a line between two points), you can do something similar for a 3D vector. (getting all three components by getting the differences between the position of your entity and the player.) Then you just accelerate the entity along that vector, multiplying the x/y/z components by how powerful you want the launch to be. 

That probably sounds like gibberish, but basic idea is you need to add x/y/z velocity to your entity based on the x/y/z distances between it and the player.