How to make a camera follow a instantiated object ? with this code
{ public Transform hedef = GameObject.FindWithTag("Player").transform;
void LateUpdate()
{
if (hedef.position.y > transform.position.y)
{
Vector3 newpos = new Vector3(transform.position.x, hedef.position.y, transform.position.z);
transform.position = newpos;
}
}
}
Answer by streeetwalker · Apr 16, 2020 at 06:16 PM
Hi @abdullahuzun, you have to give us more information:
Follow how? Look at? Or What? If the object moves, you want the camera to also move? And also look at the object at the same time? If so, at what distance from the object?
Please be specific, because there is no indication of anything moving, so "follow" doesn't make much sense.
If you want a camera to look at an object, check out Transform.LookAt in the documentation.
Answer by abdullahuzun · Apr 17, 2020 at 10:19 PM
The camera will follow it when the object goes up on the y axis, but will remain fixed when it is directed down. and this object is clone object. the code above follows the prefab and performs its task but the clone does not follow the object . What can I do to have the camera follow the clone object as desired?