Rotate around my character

Hi,
I would like to rotate around my character with the mouse (horizontal and vertical axis).However, I’m not sure how can I do that.

I can rotate my camera on itself, but what should I change to rotate around my hero.

if (Input.GetMouseButton (0)) {
          
          
            transform.position = Target.TransformPoint (new Vector3 (0f, 2f, -10f));
            transform.Rotate (new Vector3 (Input.GetAxis ("Mouse Y") * 350, Input.GetAxis ("Mouse X") * 350, 0) * Time.deltaTime);
          
        }

You could try putting a movement/rotation script onto the camera so that it uses the mouse for input & then have the camera always target the player.

Use Transform.RotateAround()

transform.RotateAround(Target.position, Target.up, 90 * Time.deltaTime);

However, my camera rotate on itselft and not around the target.

You set the player as the target?

If I remove : transform.position = Target.TransformPoint (new Vector3 (0f, 2f, -10f));

The RotateAround works, but If My character move, the camera doesn’t follow the target.

Basically, my first code works, but I would like the camera look at the character.
If I use LookAt, the camera doesn’t move at all.

With RotateAround the camera doesn’t keep the -10f distance.

Is there a way with LookAt to look at the target, but be able to rotate the camera ?

Is the camera set as a child of the parent?

Oh snap…

I forgot to set the camera as child with the new code.

Ted,
do you know a way to modify the rotation the same way that the positon.

Origin = Target.TransformPoint (new Vector3 (0f, 2f, -10f));

Not off the top of my head & I don’t have access to a PC to test anything, sorry.

Try this link, I have it bookmarked. He explains what he is doing & also has the code for different types of camera scripts

You need something like this:

transform.rotation = Quaternion.LookRotation(target.transform.position - transform.position);

I cant test this right now too see if the positions are the right way around, but this should make your camera look at the target.

Hey, another question.

Do you know why for quaternion/rotation the x is the first value and for a position x is the second value ?

OriginRot *= Quaternion.Euler (25f, 0f, 0f);

        Origin = Target.TransformPoint (new Vector3 (0f, 8f, -15f));

X seems to be horizontal for position and vertical for rotation.