Problem with camera’s

Updated on April 19, 2017 in [A] Brackeys Courses
Share on Facebook0Tweet about this on Twitter0Share on Google+0Share on Reddit0
0 on April 19, 2017

Hi, I’m doing the new “How to make a video game in Unity” course from Brackeys.

However, I’m experiencing a problem with the “follow player” function on the main camera.
When the player leaves the Ground object (might be when it touches the corner) i get an error. If the player just slides of the edge, there no problem.

It happens sometimes when leaving the edge and the trying to get back in. It’s like the player object disappears for some reason, but i have no code that destroys the object.

I get this error:
transform.position assign attempt for ‘Main Camera’ is not valid. Input position is { NaN, NaN, NaN }
Also get these errors at the same time: http://i.imgur.com/63JNyVA.png

Here is a gif video showing when it happens: http://i.imgur.com/bEC9TFl.gifv
and this is the FollowPlayer script:

 using UnityEngine;
 public class FollowPlayer : MonoBehaviour {
 public Transform player;
 public Vector3 offset;
 // Update is called once per frame
 void Update () {
 if (player != null && transform != null)
 transform.position = player.position + offset;
 }
 }
 

I hope someone can help me understand what happens :-)

  • Liked by
Reply