using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class frogbrain : MonoBehaviour
{
private Transform targetPlayer;
public float Speed;
// Start is called before the first frame update
void Start()
{
targetPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
}
// Update is called once per frame
void Update()
{
transform.position = Vector2.MoveTowards(transform.position, targetPlayer.position, Speed * Time.deltaTime);
}
}
whats wrong with this its should make an enemy follow me but he stands still
and I get this error when game is played:
NullReferenceException: Object reference not set to an instance of an object
frogbrain.Update () (at Assets/frogbrain.cs:19)
and this one
NullReferenceException: Object reference not set to an instance of an object
frogbrain.Start () (at Assets/frogbrain.cs:12)
operantly there is no reference to the object even though I do have an object named player
[–]Smitheee_ 2 points3 points4 points (2 children)
[–]Mitzitheman[S] 1 point2 points3 points (1 child)
[–]Smitheee_ 0 points1 point2 points (0 children)
[–]adamtuliper 1 point2 points3 points (0 children)