# How do I Teleport an NPC when it is distancing itself?

Get help using Construct 2

### » Fri Jun 30, 2017 1:30 pm

A little question, I'm creating a game where a drone should follow the main character, but the big problem is that it (the drone) hangs on some platforms

I do not want to have to turn off the drone collision, is there a way to in certain X or Y the Drone teleport to near the player again?

My English is very bad, sorry if anyone has difficulty understanding the topic.
B
3
Posts: 3
Reputation: 181

### » Fri Jun 30, 2017 2:18 pm

You can measure the distance between the player and the drone using the distance system expression, and lets say if its bigger then 200 px then you teleport the drone to player xy location.

distance(x1, y1, x2, y2)
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,377

### » Fri Jun 30, 2017 2:26 pm

imhotep22 wrote:You can measure the distance between the player and the drone using the distance system expression, and lets say if its bigger then 200 px then you teleport the drone to player xy location.

distance(x1, y1, x2, y2)

Thank you man, it worked.
B
3
Posts: 3
Reputation: 181

### » Fri Jun 30, 2017 4:17 pm

Update

The term "Distance" works fine, but it requires a relatively large difficulty for those who have little experience in Construct 2, so I researched and found a much simpler method, consisting of the use of Behaviors "Line of Sight"

I applied this Behaviors in the Drone in question (it can be in the player too, it makes no difference in this case)

And I have changed the following options

-Obstacles: Custom (formerly Solids)
-Range: 150 (goes out of your necessity)
Do not forget to look if the cone of view option is 360 °

And I created the following event

Drone>Has Line of Sight to> Player> Drone Set position> Player

In the "Has Line of Sight to> Player" part, right click and select the Invert option

Drone>Has Line of Sight to> Player> Drone Set position> Player
B
3
Posts: 3
Reputation: 181

### » Fri Jun 30, 2017 4:35 pm

Great, there is always more then one method to do it
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,377