using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectFollowCamera : MonoBehaviour
{
public Transform cameraToFollow;
public Transform objectToFollow;
public float distanceFromCamera;
private void Update()
{
objectToFollow.position = new Vector3(cameraToFollow.position.x,cameraToFollow.position.y,cameraToFollow.position.z - distanceFromCamera);
}
}
This script is attached to a empty GameObject. The objectToFollow will move once i'm moving the Player with the keys. But when i'm rotating the camera of the player around the objectToFollow is not moving.
The Player have attached to it: Character Controller , First Person Controller , Rigidbody
And the Camera is child of the Player.