How can i move player?


#1

Hello
How can i move player?
NOT teleport
I need an effect like when player press W
I have an idea - spawned entity (for example chiken) behind the player can move him
But mabe there are more useful ways?


#2

To move a player without teleporting. You need to offer a Key.VELOCITY to the entity


#3

Thanks
player.offer(Keys.VELOCITY, new Vector3d(1, 0, 0));
Do you know, i have to count the Vector3d to push player straight or Sponge have tools to get Vector3d from facing point?


#4

Yep. So by getting the Transform of the player. Then get the rotation of that (it is the players rotation - x = pitch, y = yaw, z = roll) after that you will need to convert that into xyz (I believe there is one that converts it into a Direction and then direction can easily be converted into a vector).

Sadly there is currently no sponge api on converting a entities looking direction into movement


#5

The category Server Discussion is not appropriate for this kind of questions. You should ask in the Plugin Development category, or you can join us on Discord to get faster answers. :slight_smile:


#6

You can do this by converting the value into a Quaternion with Quaternion.fromAxesAnglesDeg(). Then you can convert that back into a Vector3d you can use by calling getDirection().