Hello there!
I am new to Unity. Have experience with game programming in C++ and SDL. I am aware of the entity-component system.
My question is regarding a simple camera follow.
Why is this code not working:
using UnityEngine;
using System.Collections;
public class CameraFollow : MonoBehaviour
{
public GameObject target;
void Start()
{
}
void Update()
{
transform.position = new Vector3 (target.transform.position.x, target.transform.position.y, transform.position.z);
}
}
But this one is:
using UnityEngine;
using System.Collections;
public class CameraFollow : MonoBehaviour
{
public Transform player;
void Start()
{
}
void Update()
{
transform.position = new Vector3 (player.position.x, player.position.y, transform.position.z);
}
}