#applyKnockback

1 messages · Page 1 of 1 (latest)

rotund ice
#

how would you use applyKnockback to knock an entity back a set amount of blocks same way a knockback sword would, the way youre facing?

lucid tulip
# rotund ice how would you use applyKnockback to knock an entity back a set amount of blocks ...

Well , to specify the direction of the knockback you first need an angle, I guess the best thing would be to just get the horizontal rotation of the player.

Then just use trigonometry or a vector function to get the right x and z direction values, basically just get vectorial components of a 2 2d vector with a magnitud of 1 and an angle of whatever angle you whatever the player's horizontal rotation is, and use that for your kncknback x and z directions.

As for the horizon and vertical force, idk how they work exactly so just play around with the values until you get the desired effect

#

.
If you wanna more details about how to get the vectorial components of an vector with a certain angle and magnitude, just google "Polar coordinates" is just transforming polar coordinates into cartecian coordinates