Camera problems... help pls?

Hello there, im trying to make a game where my camera is similar to the Tales of Berseria. On Tales the camera goes around the player on the X and Y axis (the Y axis has a limit), it has a zoom in and out (with limit) and the camera can collide with walls, bringing it closer to the player (and when it stops colliding, she goes to her normal position)

I am a noob at unity and this is how far i could get:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraSeguir : MonoBehaviour{
public float turnSpeed = 4.0f;
public Transform player;
public RaycastHit hitpoint = new RaycastHit ();
public float smoothing = 5f;
private Vector3 offset;
void Start () {
offset = new Vector3(player.position.x, player.position.y, player.position.z);
GetComponent ().fieldOfView = 20f;
}
void Update () {
if (Input.GetAxis (“Mouse ScrollWheel”) > 0)
{
GetComponent ().fieldOfView–;
}
if (Input.GetAxis (“Mouse ScrollWheel”) < 0)
{
GetComponent ().fieldOfView++;
}
}
void FixedUpdate() {
Vector3 TargeCamPos = player.position + offset;
transform.position = Vector3.Lerp(transform.position, TargeCamPos, smoothing * Time.deltaTime);
if (Physics.Linecast (transform.position, player.position, out hitpoint))
Debug.DrawLine (transform.position, player.position);
}
void LateUpdate()
{
offset = Quaternion.AngleAxis (Input.GetAxis(“Mouse X”) * turnSpeed, Vector3.up) * offset;
transform.position = player.position + offset;
transform.LookAt(player.position);
}
}

My camera rotates on the X axis, follows the player and has an zoom in and out. What i want to now know is how to make it rotate on the Y axis aswell (with limit), put a limit on the zoom in and out and how to use my raycasthit to bring the camera closer when it hits a wall and to return it when there is no collsion.

Sorry for my bad english, i already tried to see the documentation and some tutorials on youtube but i cant get it done… If you guys give me any advice or tell me what code to use, I thank you.

Only 2 comments - hopefully both useful - to get you some additional help.
I found that using the Example 3rd person camera was a great place to start. For me, it wasn’t perfect, and I made some adjustments, but you can either look it over and/or use it directly (comes with a camera prefab, in the same package, too).
Oh, and that package ( I think it’s the same one) also contains a PreventWallClip script (not sure if that’s exactly its name), which you could use as-is or modify :slight_smile:

Second suggestion is to use code tags on the forum, which help reading a little bit. :slight_smile:

i tried to use the PreventWallClip but it doesnt work…

Hm. I have used it before and it was working. For a thorough test, did you try it with the 3rd person camera prefab and set it up with that? You didn’t mention if you tried the prefab + other script, with regard to the other portion of your post asking about limiting the rotation.