Hi all, apologies if I shouldn’t be posting this here - I’m pretty new to all of this.
I’m trying to get a system working where the camera can orbit around an object while I’m holding a mouse button after initially zooming in on the front-face of the target.
It’s all working however I’m also trying to clamp the X rotation so I’ve added code that should give me a -360 to 360 range as I left from the initial position left or right. I’m expecting a MINUS when I pan to the left (from the initial zoom location) and a PLUS when I pan to the right (from the initial zoom location). I’m then using this result to prevent further panning if either of these are outside of my allowed min/max limits.
The problem I’m getting is that it works with some targets but not with targets that face the opposite direction, as I’m getting PLUS when I pan to the left and MINUS when I pan to the right (so the opposite).
I obviously need to take into account the direction the target is currently facing when working out the rotation but I’m not sure how to do this.
I’m sure this is something really simple but I’m not smart enough to know, so any help would be much appreciated!
Here’s how I’m calculating the amount I’ve panned currently:
Vector3 angle = initialPosition - transform.position;
Thanks so much!