Recently I had decided to give network ownership of the vehicle to the player (for reasons), setting the network ownership of the part containing all my body movers to the player.
However this seems to have made my body movers to stop working?
Script setting network ownership to player, in server script service
local function giveModelToPlayer(player, model)
print(player)
print(model)
local Root = model:FindFirstChild("RootPart") -- The part containing the bodyvelocitys
Root:SetNetworkOwner(player)
end
game.Players.PlayerAdded:Connect(function(player)
giveModelToPlayer(player, workspace.Submarine)
end)
The local script, in player character scripts
userInputService.InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.One then
print("One")
SubRootPart.BodyVelocity.MaxForce = Vector3.new(10*144000, 0, 10*144000)
SubRootPart.BodyVelocity.Velocity = SubRootPart.CFrame.LookVector * 0
elseif inputObject.KeyCode == Enum.KeyCode.Two then
print("Two")
SubRootPart.BodyVelocity.MaxForce = Vector3.new(10*12000, 0, 10*12000)
SubRootPart.BodyVelocity.Velocity = SubRootPart.CFrame.LookVector * 100
elseif inputObject.KeyCode == Enum.KeyCode.Three then
print("Three")
SubRootPart.BodyVelocity.MaxForce = Vector3.new(10*24000, 0, 10*24000)
SubRootPart.BodyVelocity.Velocity = SubRootPart.CFrame.LookVector * 100
elseif inputObject.KeyCode == Enum.KeyCode.Four then
print("Four")
SubRootPart.BodyVelocity.MaxForce = Vector3.new(10*48000, 0, 10*48000)
SubRootPart.BodyVelocity.Velocity = SubRootPart.CFrame.LookVector * 100
end
if inputObject.KeyCode == Enum.KeyCode.W then
end
end)
Mmmh… Its weird. I used ur code, and works! I didnt change anything I just added references for a quick test on my place, and works as expected. Theres something else you maybe missing?
Server script
local sub = game.Workspace.Model
local function giveModelToPlayer(player, model)
print(player)
print(model)
local Root = model:FindFirstChild("RootPart") -- The part containing the bodyvelocitys
Root:SetNetworkOwner(player)
end
game.Players.PlayerAdded:Connect(function(player)
giveModelToPlayer(player, sub)
end)
Local script
local userInputService = game:GetService("UserInputService")
local SubRootPart = game.Workspace.Model.RootPart
userInputService.InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.One then
print("One")
SubRootPart.BodyVelocity.MaxForce = Vector3.new(10*144000, 0, 10*144000)
SubRootPart.BodyVelocity.Velocity = SubRootPart.CFrame.LookVector * 0
elseif inputObject.KeyCode == Enum.KeyCode.Two then
print("Two")
SubRootPart.BodyVelocity.MaxForce = Vector3.new(10*12000, 0, 10*12000)
SubRootPart.BodyVelocity.Velocity = SubRootPart.CFrame.LookVector * 100
elseif inputObject.KeyCode == Enum.KeyCode.Three then
print("Three")
SubRootPart.BodyVelocity.MaxForce = Vector3.new(10*24000, 0, 10*24000)
SubRootPart.BodyVelocity.Velocity = SubRootPart.CFrame.LookVector * 100
elseif inputObject.KeyCode == Enum.KeyCode.Four then
print("Four")
SubRootPart.BodyVelocity.MaxForce = Vector3.new(10*48000, 0, 10*48000)
SubRootPart.BodyVelocity.Velocity = SubRootPart.CFrame.LookVector * 100
end
end)
I also had another body velocity inside of the root part which helps preventing the model from falling, but I doubt that’s the reason why its not working. https://gyazo.com/07e7bff1dffeeff342b78af9b873356f
What happens when u press the 3 key? Literally nothing? Theres no more parts u added that are anchored or something?
That another bodyvelocity, I dont think thats the problem, but u tried to disabled it, and do the test? put the model on ground and test if reacts to the keys
Yup, it was the mass of the model. It has lots of parts! Should be massless, or you will need to increase the power of the bodymover to very high values. I only changed the Custom Density of the RootPart to 0.01 and made all other parts massless. Now it moves
Edit: Well actually on the first test I did when I deleted all the parts and only using the RootPart, it wasnt moving either. Probably the RootPart is very huge which causes a lot of mass, which the bodymover cant push. To be honest idk if the parts welded to the RootPart increase the mass of the entire model. But just to be sure, I changed all those parts to massless.
Hm, it moves a lot differently then before while it was done on the server script. Is there any reason why theres such a massive difference between handling it on the local script compared to on the server script?
Also, the other body velocity preventing the submarine from falling doesn’t seem to be working anymore either.
On the Yaxis bodymover you sent me, the velocity is 0,0,0. Maybe thats why is not working.
You were controlling the bodymovers on local script? weird, thats not possible. Bodymovers only reacts on server side. What u mean by handling it on local script?
Edit: Sorry i was confused about that. Yeah u are right now you are feeding the values from local script
As you can see in my original post, I had mentioned I gave network ownership of the submarine to the player. This should, as far as I know allow the physics to be handled client side instead.
Yup. When u set the network owenership to the player, now its client is doing the math, which leads to a better experience for that client. When you were controlling the bodymovers on server, how the handling was working? that server handling should have a delay which is not good to experience while riding any vehicle. But actually, the closer character gets ownership, when the server detects it. So, you were experiencing almost the same effect when you set it manually or when you wait for the server to give the ownership to the nearest player
EDIT: BTW. You can fix the movement if you feel it weird, by just editing the bodymover values, as velocity and p, and the mass of the RootPart too. Just play with those values until you get what u want
What u get when u test it? I tested right now, and the YAxis is keeping the submarine floating on thin air, while rotating like crazy, thats expectable, cause bodyvelocity doesnt respect the orientation
And I did not changes to that. I just changed the mass of parts
I see… we got confused… Im testing it, and experiencing weird problems. Due to both bodyvelocities working on the same part. Actually its only working with the first bodyvelocity that is parented inside the RootPart, and ignoring the second one. if you remove one, place it on server storage, then place it again on the RootPart. You will see that the placement order changes. And behaves differently, if the XAxis is the first one, then the movement doesnt work, and it floats. If the Movement bodyvelocity is the first one, the movement works and the floating doesnt.
Looks like, both bodyvelocities working together, are trying to change the same parameters at the same time. Lets fix this, I’ll be making some tests
What, I had been able to use two body velocitys in the same part when handling the body movers on a server script. How would moving it to a local script be any different?
Thats a good question. But. Why that post is saying its not possible to use 2 bodyvelocities in the same part? Is that post wrong?
I hardly think that the problem depends on server or client. But it could be. I think we need more tests…
I love vehicles and I built a very cool aircraft. I will keep testing with ur submarine. I want to see this beautiful submarine working. Btw you did a great design!
Edit: BTW. @DevTestDummy says that using BodyPosition. Could work for the YAxis