delay means when i move it takes a while for the turret to move
basically input delay
delay means when i move it takes a while for the turret to move
basically input delay
It’s biased of you to say that as you created that. Furthermore, body movers are considered legacy movers therefore not long term and deprecated.
That’s due to the turret speed that I have pre-set, that does not classify as “lag/delay”.
the turrent movement might just be what I wanted, how did you do that?
Connect the turret using constraints, so it has movability to your needs, then add a BodyGyro
, and use RunService
to make the BodyGyro
constantly face the Part
.
how about the yawing of the turret? i’ve had trouble scripting that for the last 5 hours. is it the same?
I’m not sure exactly what your trying to do with the turret, from the picture you showed above, are you trying to make the whole turret rotate? or only the middle bit?
I have a turret that I made for my game and turned it to a model just like you described it in your post
It uses a hinge constraint to freely rotate around the player (so its physically simulated)
Feel free to use it and modify it to your liking if you want! (or look at the script for reference)
No credit is needed if you do use it
Using a crazy module and everything is rather overcomplicating it. You can just use some basic cframe stuff to solve for the angles.
First you want to get the vector facing the target. You can do this by doing local direction = (gunPosition - targetPosition).Unit
.
Next you’ll want to get the horizontal angle first, and you can do that by remove the y direction of the facing vector.
local horizontalVector = direction * Vector3.new(1, 0, 1)
After that, you can get the vertical vector like so:
local verticalVector = direction * Vector3.new(0, 1, 1)
From there, you can get the base’s CFrame by doing base.CFrame = CFrame.lookAt(base.Position, base.Position + horizontalVector)
The barrel is a little more complex but nothing difficult:
barrel.CFrame = CFrame.lookAt(base.Position, base.Position + verticalVector) * CFrame.new(0, 0, -barrel.Size.Z/2)
If you have any issues/questions let me know!
Does “Unit” refer to the X, Y or Z axis?
Unit means the unit vector of subtracting both the gun position from the target position. This is a unit vector facing the direction the turret is suppose to aim. It means all axies.