Hi all.
I was trying to create a script to use the right stick to rotate around my player (follow)
I played around with RotateAround. I can’t get the camera to orbit the player no matter how much I strip the code (See below).
I’m not looking for an alternate / better method. I’m just trying to understand why the following will not rotate the camera around the target but just seems to spin around itself with the transform position remaining static.
I know the transform.position and rotatetowards are “fighting” each other. But even with the left stick still it will not rotate the camera around the target object.
Thanks for any input.
void LateUpdate()
{
RightStick();
Vector3 follow = new Vector3(followXForm.position.x, followXForm.position.y, followXForm.position.z);
Vector3 offset = new Vector3(0, yDistance, -zDistance);
Vector3 target = follow + offset;
float xD = Mathf.Abs(transform.position.x - target.x);
if (xD >= xDistance)
{
Vector3 ps = new Vector3(target.x, target.y, target.z);
transform.position = Vector3.Slerp(transform.position, ps, Time.deltaTime * smoothMovement);
}
}
void RightStick()
{
// right stick camera
//different code before but testing rotatearound
transform.RotateAround(follow, Vector3.up, smoothRotate * Time.deltaTime);
}