Hi, I’m working on my own Space-craft piloting system and I’m just looking for the best way to go about it?
Currently, my system uses the Vehicle Seat to steer, turn etc. etc. However, I’ve noticed this can cause some Ping increases on the server.
I was wondering if anyone else has any other ideas which would work out much more friendly?
Is the ship network owned by the player? That could help reduce stress on the server as the client could calculate the physics and would not need to fire the server.
You should also try to implement a mouse based control system. All games with aircrafts have them because it is much easier to point to the right direction with a mouse instead of tapping on keys.
The easiest way to do this is to subtract the mouse’s position from the screen’s center, clamp it to the maximum distance from center to use and divide by it. You will get a vector between -1 and 1 which you can multiply by the max rotation (maximum rotation velocity * time delta).
Also, a good practice would be to clamp the vector to a radius (magnitude always below maximum rotation) to avoid players abusing pointing at corners for faster turns.
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local scrgui = --screengui
local maxoff = 100 --maximum distance from center in pixels
local maxrot = 20 --how much you want to rotate each second
game:GetService("RunService").Heartbeat:Connect(function(dt)
local dir = Vector2.new(
math.clamp(mouse.X-scrgui.AbsoluteSize.X,-maxoff,maxoff)/maxoff*maxrot*dt,
math.clamp(mouse.Y-scrgui.AbsoluteSize.Y,-maxoff,maxoff)/maxoff*maxrot*dt,
)
if dir.magnitude>maxrot*dt then dir = dir.Unit*maxrot*dt end--avoid faster turning at corners
--now you can use this value whatever way you want
end
This method seems quite reliable.
I’m still in the midst of expanding my work with FE due to taking time away;
but, getting the mouse - Would this not be entirely client based? Meaning that the ship would only move and rotate on the client itself as opposed to all Players?
Set the network ownership of all parts to the player who controls it. Anything that happens on that player’s game replicates to the others (anchoring, collision, movement).