How to change TPS camera angle in Unity

by JonS   Last Updated October 10, 2019 01:13 AM - source

I'm very new to UNity and this may simply be a failure of google fu but I hope someone here can help me out.

I'm working through a series of tutorials on how to create an RPG in unity, making small improvements and embellishments as I go to make sure I understand the concepts. I've built a player character with walk and run animations and a camera which follows the player around and stays aimed at the centre of the character model using the following code.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraFollowPlayer : MonoBehaviour
{
    GameObject target;

    // Start is called before the first frame update
    void Start()
    {
        target = transform.parent.gameObject;
    }

    // Update is called once per frame
    void Update()
    {
        transform.LookAt(target.transform.position);
    }
}

The problem with this is the angle this leaves the camera pointing at in-game is to acute, making it difficult to see what is ahead of the character. How can I adjust the target of the LookAt instruction to result in a shallower X-axis rotation of the camera?



Related Questions


Camera bounds on different resolutions

Updated February 22, 2016 01:05 AM

Disable global fog from camera

Updated December 27, 2016 08:05 AM

Unity 3rd person Camera and restrictions done wrong

Updated March 30, 2017 05:13 AM

Checking if object passed between two other objects

Updated April 14, 2015 20:05 PM

Unity C# 2D Platformer Enemy Patrolling

Updated April 03, 2015 21:22 PM