i use this script to rotate a object called “A”, which is a child of a car, but no matter where the car towards, “A” will be rotating around world-Z-axis.
yet I want the “A” to rotate around the Z-axis of the car, instead of the world Z-axis.
i hope some experienced ppl can help me with this, btw, simply change the code to localTransform doesn’t work.
var tiltAroundZ = Input.GetAxis("Horizontal") * tiltAngle * -2;
var vector = Vector3(0, 0, tiltAroundZ);
var target = Quaternion.Euler (vector);
transform.rotation = Quaternion.Slerp(transform.rotation, target,Time.deltaTime * smooth);