Hey, Kami
The main issue here is that your code doesn't push player towards any particular location. Instead it treats your coordinates as a vector to add to the player velocity.
See, if you use type
pushto 2 0 0 1000 (2 is my userid), your code will just add the vector (0, 0, 1000) to player's current velocity. That means that if a player was standing still, he'd get pushed straightly upwards, and his initial speed will be 1000. The point of the map located at (0, 0, 1000) doesn't play any role in your implementation.
Try this:
Syntax: Select all
from commands.typed import TypedSayCommand
from mathlib import Vector
from players.entity import Player
@TypedSayCommand('!pushme')
def say_pushme(command_info, x:float, y:float, z:float):
player = Player(command_info.index)
player.teleport(None, None, Vector(x, y, z) - player.origin)
Usage:
!pushme 0 0 0 (chat command)
This will push the player
towards point at (0, 0, 0). Depending on how far that point is from the player, pushing velocity will vary.
I use
player.teleport to set velocity to players. Its arguments are
new location,
new angle and
new velocity. I don't need to change player's location or angle, so I just pass
None.
But be aware that
player.base_velocity (that's a shortcut for what you use in your code) will
add the velocity;
player.teleport sets the new velocity. So in my code it doesn't matter what the player velocity was before they typed the command.
If you need their old velocity to be taken into account, you can do it this way:
Syntax: Select all
player.teleport(None, None, player.velocity + Vector(x, y, z) - player.origin)