Rotation in 3d (advanced)

Hello,

I’m working on a game where an object moves towards a waypoint.
i also let the object look at that waypoint with the following code:

var rotate = Quaternion.LookRotation(target.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * 2);

But the problem is that i want to Tilt the object backward with 30-50 degrees.

Can i use the transform.rotation function to look at the waypoint horizontally, instead of horizontal and vertical. so i can manually set the horizontal rotation to around -30 degrees.

thanks,
Aymeric Blok

Give it a go with:

transform.rotation = Quaternion.Euler(x,y,z);

With this you can control each rotation invidually.

well that’s not what i search for. thats beginner 3d rotation. and the problem is to acquire the right x value.
So with higher Maths i have to calculate the degrees where to move towards the target

An easy solution to this is to put the object inside an empty parent object. Then, use the parent for left/right rotation and tilt the child independently.