hi guys… i have this rotation problem that i would love to get some help about it…
here is the thing… i have a 2 piece canon attached to a vehicle… my aiming system pick a point in the world that should be my target… and i use the LookAt function to rotate the canon base, only in the Y axis, to face that point…
Vector3 relativePos = target.position - transform.position;
Quaternion rotation = Quaternion.LookRotation(relativePos);
rotation.x=0;
rotation.z=0;
transform.rotation = Quaternion.Slerp(transform.rotation,rotation,Time.deltaTime*4);
everything works great when the vehicle is on a flat ground… when i go over a hill or something, changing the rotation of the vehicle itself, the canon’s X and Z rotation does not follow up…
i understand what is wrong with the code… but i can think in a way to solve this… thanks in advance…