Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Vector2.Distance question. Code isnt working. Keeps throwing errors.

$
0
0
I'm trying to determine if the distance between my player and enemy is greater than the minimum distance. Then I'm moving the enemy toward the player. However the code i'm using in the if statement to check the distance keeps throwing an error. It says object reference not set to an instance of an object. If anyone could help that would be awesome! Here's the code: if (Vector2.Distance(transform.position,player.transform.position) >= minDistance) { //moves enemy towards enemy// transform.position = Vector2.MoveTowards(transform.position, player.transform.position, speed * Time.deltaTime); }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>