Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

How to detect wether an object is headed towards the top or bottom of an object?

$
0
0
Im working on enemy AI for my game and I have a problem. The enemy has a collider on it and I want it to check for another objects distance (projectile). If the projectile is aimed towards the top of the enemy object, then the enemy should move downwards and if the projectile is aimed at the bottom the enemy should move upwards. I have got a vector2.distance method setup to measure the distance between the enemy and projectile but I want to check if the projectile is aimed at the top or bottom and if the distance of the projectile to the top for example is less than the distance to the bottom then let the enemy `AddForce(transform.down * 800 * Time.deltaTime);` So its like dodging the projectile. ![alt text][1] [1]: /storage/temp/50070-untitled.png

Viewing all articles
Browse latest Browse all 1488

Trending Articles