Disclaimer, not sure if this is a building or scripting issue
I have an excavator that uses a mixture of welds and constraints to move around. The main body rotates with a weld, and the boom arms are controlled by rod constraints with hinges. Ideally, it would rotate smoothly all the time, but I’m having an issue where the constraints seem to freeze up when I rotate the body (see attached video). It only seems to do this when I rotate the whole upper section left or right, and its always that lower arm. Moving any other part of the assembly immediately fixes the problem, but it continues to occur sporadically. I haven’t tried anything to fix it yet because I’m not really sure what the problem is…
I’d appreciate any ideas. Thanks!
1 Like
Hiwi o/
I did run into some similar proplems before by different reasons.
Questions.
Why not using a hinge on servo to rotate the main body too?
The arm has only one hinge on the base of it? I mean where the arm connects with the mainbody has only 1 hinge? or it rotates left/right and up/down?
Why using the rods? I think is enough using the hinge on servo actuator
My first ideas are:
-
How are you feeding the hinges and the mainbody? By CAS, by inputService? or by the default roblox vehicle seat? (which is the most glitchy one)
When u press left or right, it get stucked into a previous value and overlaping with the another one, that use to happen when pressing both keys at the same time or quicly one after another.
-
Network Ownership. Maybe the player has not enough ownership of the physics of the arms, so arms are glitching. Check that player has complete ownership
-
That happened to me, when I tried to use 2 bodygyros to control a turret too, this is not ur scenario, but, im just saying
-
Collisions? :v (well thats just silly, but double check its not that bad)
-
The script is wrong. Thats impossible to know without looking at it.
Thanks for the suggestions.
I’ve thought about a hinge–it was just easier for me during setup to use a weld and rotate the welds CFrame. YOu are correct that the arm only has 1 hinge. I am using rods so that it better simulates the hydraulics of the machine. In real life excavators move the arms via retracting hydraulic cylinders. The rods do a very good job of mimicking that.
I am using a client sided input script that fires a remote event to the server when a key is pressed. So the client tells the server to turn left, and the server turns the machine left until the client sends another signal to stop turning.
I’ll look into the network ownership…not sure if that would impact it though. The client only sends the signals to tell the server to move the machine.
Here is a sample of the code used to rotate the machine server side:
function DD(p)
if player == nil then return end
if p ~= player then return end
dd = true
DKey()
end DDown.OnServerEvent:connect(DD)
function DU(p)
if player == nil then return end
if p ~= player then return end
dd = false
end DUp.OnServerEvent:connect(DU)
local dw = false
function DKey()
if dw == true then return end
dw = true
if mode == 1 then
while dd == true do
wait()
seat.Parent.Cab.Rotate.C0 = seat.Parent.Cab.Rotate.C0 * CFrame.Angles(0,math.rad(1),0)
end
elseif mode == 0 then
while dd == true do
wait(.1)
seat.Parent.Tracks.BodyGyro.CFrame = CFrame.Angles(math.rad(0),math.rad(seat.Parent.Tracks.Orientation.y -5),math.rad(0))
end
end
dw = false
end
By that little example. My first idea is that the while loops are not properly stopping when you fire the another while loop.
The problem could be on client side too, so its needed too.
On my experience building vehicles and machines, using many loops its a bad approach. Unless you take special care to stop them on sync when client press different keys. So, only using 1 main while loop on renderStep() (use another wait(), cause RS only works on client) that control ALL movements, and when the client press a key you only change variables and the main loop will use those vars to feed the movement.
For example when client presses Left key, vars becomes -1 and when client presses right becomes +1. So the while loop its feeding different values and it never stops until the “engines” are turned off.
I can read, “seat” on ur script. Maybe you are using the normal Seat which is the best, if you are using the VehicleSeat, I suggest get rid of it, and script all functions by CAS. You mentioned you are using inputService? Its needed to check the local script to see if it contains enough locks, in order remotes are not firing at wrong times to the server.
For now, I can just suggest advices, cause I would need to check the whole system (turning part) and test it to find the errors.
Try to fix it, rebuilding the turning system by using only one main while loop.