Quantcast
Channel: Questions in topic: "follow"
Viewing all articles
Browse latest Browse all 536

Move enemy towards player if enemy is in Camera bounds.

$
0
0
Hey, it is my first question here and I did some research before asking, but if I missed something I am so sorry. I will get to the point : I have script that makes Enemy move towards my Player (it is 2D platformer). Enemy move if distance between Player and object is less than max dist. but if I reach higher value with my Player than max dist Enemy stops following. if (Vector2.Distance(transform.position, Player.transform.position) <= 10.0f) { Vector2 enemyVelocity = new Vector2((transform.position.x - Player.transform.position.x) * Speed, 0); rgBody2d.velocity = -enemyVelocity; anim.SetFloat("Speed", enemyVelocity.magnitude); } How can I make follow my player if it shows in Camera and do not stop until it reaches the Player? I would be thankful even for some links so I can manage with this by myself.

Viewing all articles
Browse latest Browse all 536

Trending Articles



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