Open Gjum opened 8 years ago
We have that in the interact plugin, but maybe it should go into movement, and I'm also not sure if it works together with the physics plugin right now.
Physics suspends itself when Spockbot is mounted on a Vehicle. I have no problem with this stuff staying in interact or movement. But if the vehicle movement is truly based on the client's yaw than we should have a way to translate between absolute (move positive x, negative z) and relative (forward, backwards) so plugins that want absolutle movement don't have to mess with yaw.
Example: A bot controlling a boat probably doesn't want to mess with head direction and forward/backwards. It just wants to move in a certain direction. We should automagically handle the head yaw
plugins that want absolutle movement don't have to mess with yaw
:+1:
Two options when moving north when looking west:
It should also be noted that when a steering packet is sent and the yaw changes after that, the intended movement might not be achieved, because the server always uses the current yaw to calculate movement and not only the yaw when receiving the steering packet.
I prefer 1, although 2 might be useful in cases where having a certain yaw is important (block placement, NCP).
@nickelpro is it ok with you if I put the vehicle controls into Physics.move_*()
and .jump()
etc.?
That makes sense for me, because when physics is suspended, movement happens by sending Steer Vehicle
rather than Player Position
.
It makes the plugin more complex though.
When riding a minecart, look
and steer
get sent every tick (even when they don't change), but position
doesn't:
# not mounted, normal movement packets
# if nothing changes, position gets sent every second
client->server: play position : {"x":197.43847190544113,"y":70.63409999847413,"z":124.5,"onGround":false}
client->server: play position : {"x":197.43847190544113,"y":70.47886799395752,"z":124.5,"onGround":false}
client->server: play position : {"x":197.43847190544113,"y":70.24834062504456,"z":124.5,"onGround":false}
client->server: play position : {"x":197.43847190544113,"y":70,"z":124.5,"onGround":true}
# just turning the head sends look once per tick, position keeps getting sent every second
client->server: play look : {"yaw":-207.23580932617188,"pitch":8.699928283691406,"onGround":true}
client->server: play look : {"yaw":-207.23580932617188,"pitch":9.149928092956543,"onGround":true}
client->server: play look : {"yaw":-207.23580932617188,"pitch":11.249927520751953,"onGround":true}
client->server: play look : {"yaw":-198.68580627441406,"pitch":34.649925231933594,"onGround":true}
client->server: play look : {"yaw":-187.13580322265625,"pitch":59.69992446899414,"onGround":true}
client->server: play look : {"yaw":-168.5358123779297,"pitch":90,"onGround":true}
client->server: play look : {"yaw":-154.5858154296875,"pitch":90,"onGround":true}
client->server: play look : {"yaw":-153.0858154296875,"pitch":90,"onGround":true}
# moving while turning the head sends position_look once per tick
client->server: play position_look : {"x":197.43847190544113,"y":70.7125,"z":124.5,"yaw":-207.23580932617188,"pitch":8.84992790222168,"onGround":false}
client->server: play position_look : {"x":197.43847190544113,"y":70.7125,"z":124.5,"yaw":-207.23580932617188,"pitch":8.84992790222168,"onGround":false}
client->server: play position : {"x":197.43847190544113,"y":70,"z":124.5,"onGround":true}
client->server: play position_look : {"x":197.43847190544113,"y":70.7125,"z":124.5,"yaw":-207.23580932617188,"pitch":8.84992790222168,"onGround":false}
client->server: play position : {"x":197.43847190544113,"y":70,"z":124.5,"onGround":true}
client->server: play position : {"x":197.48283567607507,"y":70,"z":124.4126166254282,"onGround":true}
client->server: play position : {"x":197.55142206828864,"y":70,"z":124.2775219227984,"onGround":true}
client->server: play position : {"x":197.6332340134209,"y":70,"z":124.11637683202311,"onGround":true}
# mounting a minecart
client<-server: play.attach_entity :{"entityId":31,"vehicleId":1,"leash":false}
# different packets get sent: look and steer_vehicle once per tick, but never position or position_look
client->server: play look : {"yaw":-181.43585205078125,"pitch":36.14994812011719,"onGround":false}
client->server: play steer_vehicle : {"sideways":0,"forward":0,"jump":0}
client->server: play look : {"yaw":-181.43585205078125,"pitch":36.14994812011719,"onGround":false}
client->server: play steer_vehicle : {"sideways":0,"forward":0,"jump":0}
# etc ...
This means the Physics plugin should handle vehicle movement completely IMO.
started in Gjum@vehicle-physics
Create the API for moving around while in a Minecart, boat or horse etc. - started in interact plugin
Check for compatibility with
physics
. - done, works