I have made the turret of my tank rotate towards the players’ Mouse.Hit.Position only along the Y-Axis. It works fine while the vehicle is stationary or moving forward/backwards, but when the vehicle is turning this is offset for some reason.
The vehicle uses a LinearVelocity for forwards/backwards movement and uses an AngularVelocity for turning. I can only assume this is happening because of the AngularVelocity but I have no clue how I would go about fixing this. I’ve double-checked a lot of things and I am sure that my math works. The problem persists whether I tween the rotation or not.
Although it’s deprecated, I suggest using a body gyro, you can use body gyro to turn an object to a set orientation. You can either get one from Instance.new() or just finding it in the toolbox.
Keep in mind that body gyros only takes in CFrame values
Ignoring the fact that its deprecated, what use would I have for it? I wouldn’t use a body mover / constraint to orient a part rigged to a model when I could just set a joints CFrame. My problem lies with the AngularVelocity constraint offsetting my joints rotation. Replacing the constraint with a BodyGryo wouldn’t change anything as they both accomplish the same thing.
You may want to increase MaxTorque within AngularVelocity, as it looks like the angular constraint is lagging behind the mouse movement in reaction to change.
Increasing the MaxTorque will decrease the influence from the Linear Velocity in the system:
The AngularVelocity constraint is being used to turn the entire vehicle.
The turret orientation lagging behind is a purposeful tween to make it look nice. The constraints MaxTorque is already set to math.huge and removing the tween from the turret has the same effect happening.
why don’t you add the inverse of the current turning velocity to the turret’s target cframe to counteract the turning
Although they do almost the same things, bodyGyro has power and more importantly, dampening, You can turn the power really high so other velocities don’t effect it, then turn the dampening up to retain the smooth rotation.
The best solution I’ve found so far is to simply ditch the tween in favor of lerping the joints CFrame. I still don’t know why the tween struggled to keep itself oriented the right way, but lerping the CFrame towards the new Mouse.Hit seems to work good enough.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.