Hello, i've been working alot on a tank game prototype, and it is going very well, but there is still a problem i'm not being able to fix, this problem is the tank turret rotation, i decided to use i diferrent approach to getting it done, so now i have a Spatial node that points in the direction of the hit location of a raycast that comes from the camera, and from there i rotate the turret of the tank in the Y axis and the gun of the tank in the X axis to match the rotation of this Spatial node (i know it is a bit hacky, probably, but it gives the best result of everything i tried).
here's the code:
var desired_rotation = turretG.global_transform.looking_at(cam.ray_pos, Vector3.UP)
var a = Quat(turretG.global_transform.basis.get_rotation_quat()).slerp(desired_rotation.basis.get_rotation_quat(), delta * turn_quant * turn_turret)
turretG.global_transform = Transform(a, turretG.global_transform.origin)
turret.rotation.y = turretG.rotation.y
maingun.rotation.x = turretG.rotation.x
maingun.rotation.x = clamp(maingun.rotation.x, deg2rad(depression), deg2rad(elevation))
my problem with it is that i can't keep its rotation consistent, it starts rotating fast and then it slows down when it is getting closer to its desired rotation, and gameplay wise that would not be fun to play with.
so is there a way i could make this rotation more consistent? any help would be appreciated.