I have created a legged walking vehicle (very similar to a mech). I successfully fully rigged the model before animation so that I could easily animate it. I have completed the main walking animation. The only challenge I face now is allowing the player to control this animated walker vehicle. I need a way so that the player can control the custom rigged vehicle so that they can move it in different directions such as foward, left, right, and backwards. Does anyone have any suggestions or help on how I can complete this vehicle, it would be much appreciated.
You can do what roblox does to move a player’s character: get the keys they’re pressing and use Humanoid:Move on the mech:
local up = 0 local down = 0 local left = 0 local right = 0 local uis = game:GetService("UserInputService") local rs = game:GetService("RunService") uis.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.W then up = 1 elseif input.KeyCode == Enum.KeyCode.S then down = 1 elseif input.KeyCode == Enum.KeyCode.A then left = 1 elseif input.KeyCode == Enum.KeyCode.D then right = 1 end end) -- add an InputEnded event that will set the variable of the corresponding key that was released to 0 rs.Heartbeat:Connect(function() hum:Move(Vector3.new(right - left, 0, up - down)) end)
You’ll of course need to give the player network ownership of the mech so movements and animations will replicate, unless it’s anchored
Sorry im not familiar with player network ownership. Could you explain how to implement this aswell?
Network ownership is basically assigning either the server or client to calculate the physics for physically simulated (unanchored) parts on their end and it’ll be replicated to the server and other clients with a negligible and unnoticeable delay. By default, all parts whether anchored or not, all have their network owner set to “Auto”, so the roblox engine will choose the network owner to be the client that is close to it, or the server.
You can change its network owner using the
SetNetworkOwner function of a part, where its only parameter is whatever is going to be the owner of the part that the function was called on. It can either be a player, or
nil. If nil is passed, the server will be the network owner. This has to be done on the server, hence why a server script has to be used