Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why won't my BodyForce car won't move on play?

Asked by 6 years ago

Right, so I have a car which uses body-movers to steer and to move with a few problems.

seat = script.Parent

local vehicle = seat.Parent
local DriveForce = vehicle.MainComponent.DriveForce
local Turn = vehicle.MainComponent.BodyAngularVelocity
local speed = 40000
local turnspeed = -1.5

local engineSound = vehicle.EngineSound

function getSpeed()
    return math.pow(math.pow(vehicle.MainComponent.Velocity.X,2) + math.pow(vehicle.MainComponent.Velocity.Z,2),0.5)
end

while true do
    wait()
    DriveForce.Force = seat.CFrame.lookVector * speed * seat.Throttle

    Turn.AngularVelocity = Vector3.new(0,seat.Steer*turnspeed,0)

    print(DriveForce.Force.X)
    print(DriveForce.Force.Y)
    print(DriveForce.Force.Z)
    print("------------------")

    local gearthresh = 40 + (speed*2)
    local speed = getSpeed()
    local strain = (speed % 40)
    if (speed > 40) then
        strain = strain + 33
    end
    engineSound.Volume = (strain * 0.2) + 1
    engineSound.PlaybackSpeed = (strain*0.01) + 1

end

This script is inside the vehicle seat of the car.

It works absolutely fine when you play using Roblox studio's Start or Play buttons, however, when you play the published project, there is a problem.

When you press W (to go forward), your car won't move and appears to be stuck. I've checked the print statements and the force is definitely being applied to the car, but the force won't make the car go forward.

Interestingly, the car can turn perfectly fine.

Can anybody help? I can give more information if you need it.

Thanks!

-There are no error messages

0
Have you made sure that any parts are unanchored? Adrian12094 12 — 6y
0
Is your game labeled as "Experimental Mode" under the development section of roblox.com? It's not problematic if it isn't, by the way. whenallthepigsfly 541 — 6y
0
Yes, it is filtering enabled. No parts are anchored. As I said, it works on start, so I think it's more of a network issue than a filtering enabled issue. Sporech 0 — 6y
0
You can have a look here: https://www.roblox.com/games/988203139/Test-Track I made it print the bodyforce of the car in the server log, so have a look in the console. I've just had another test (on a lower ping), and it works some of the time, but often, when you stop, your car can't start again. It's difficult to describe, so take a look. Sporech 0 — 6y
View all comments (2 more)
0
Ok, more important is if you are setting the network owner of the car to the player. If not, that would explain the difference in behavior between local play and server play, as the server does not allow players to change anything they are not the network owner of. whenallthepigsfly 541 — 6y
0
Ok, I've read up on network ownership. I get how it can help, but my car is a load of parts in a model. Which part(s) would I need to set the network ownership of? Sporech 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Ok, so it didn't turn out to be a network issue or anything fundamental, but there was too much friction on the wheels. When I set the friction on the wheels to zero, whilst it was far too skiddy, the car could actually gain traction.

Though I bet network ownership did help, as I did set the parts of the car's network owner to the client.

Ad

Answer this question