I have a problem with my Camera detecting and following the player!! pls help...
I have an issue with the Camera i don't know why it's not detecting my Player with Network ready code,for said Player. i'm trying to follow a tutorial about a third person shooter, Can anyone help me out with this code? i know i'm trying to follow a tutorial too hard for me but i'm trying to implement a game manager in my own game and it's my first working with singletons. IT'S GONNA BE NICE!!!
[CODE] using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ThirdPersonCamera : MonoBehaviour { [SerializeField] Vector3 cameraOffset; [SerializeField] float Damping;
public GameObject Player;
Transform cameraLookTarget;
Player localPlayer;
void Awake()
{
GameManager.Instance.OnlocalPlayerJoined += HandleOnlocalPlayerJoined;
}
void HandleOnlocalPlayerJoined(Player Player)
{
localPlayer = Player;
cameraLookTarget = localPlayer.transform.Find("cameraLookTarget");
if (cameraLookTarget == null)
cameraLookTarget = localPlayer.transform;
}
private void Update()
{
Vector3 targetPosition = cameraLookTarget.position + localPlayer.transform.forward * cameraOffset.z + localPlayer.transform.up * cameraOffset.y + localPlayer.transform.right * cameraOffset.x;
transform.position = Vector3.Lerp(transform.position, targetPosition, Damping * Time.deltaTime);
}
} [/CODE]
This is the Network ready code for my player i'm pretty sure something wrong in This>>>>>>
[CODE] private Player m_localPlayer; public Player localPlayer { get { return m_localPlayer; } set { m_localPlayer = value; if(OnlocalPlayerJoined != null) OnlocalPlayerJoined(m_localPlayer); } [/CODE]