How to get position of enemy
Hello!
I got a player and an enemy. I know the position of my enemy and my player. I wanna get a position a little closer to the player then the enemy is.
If i draw a line between enemy and player, the line start at 0 at player and end at 10 at enemy. I wanna get position where the line would be 9. 1 away from enemy and 9 away from player. How can i do this?
Comment
Answer by Commoble · Mar 08, 2017 at 06:15 PM
You can use Vector3.Distance or Vector2.Distance to get the distance between two positions. Example:
Vector3 distance = Vector3.Distance(this.transform.position, otherObject.transform.position);
float minDistance = 1F;
if (distance > minDistance)
{
// move closer
}
i already do that but i wanna get a position a little closer to me then the actual target is. I want something like distance - 1.
Your answer
![](https://koobas.hobune.stream/wayback/20220612112733im_/https://answers.unity.com/themes/thub/images/avi.jpg)