I’m making a zombie AI script, and when I drag-and-drop this code onto the enemy, and drag the “Player” Transform onto the transform box, the console ends up saying
something like this:
transform.position assign attempt for ‘Zombie’ is not valid. Input position is { -125138735291163730000000000000000000000.000000, 319500158179833610000000000000000000000.000000, -Infinity }.
UnityEngine.Transform:Translate(Vector3)
Zombie:Update() (at Assets/AI Scripts/Zombie.cs:13)
Here is my code:
- using UnityEngine;
- using System.Collections;
-
- public class Zombie : MonoBehaviour {
- public Transform Player;
-
- // Use this for initialization
- void Start () {
- }
-
- // Update is called once per frame
- void Update () {
- transform.Translate (Vector3.MoveTowards (transform.position, Player.transform.position, 1));
- Debug.Log (transform.position);
- }
- }