How do I set the line of sight to go to the closest object?

Get help using Construct 2

Post » Wed May 20, 2015 12:38 am

If I move my line of sight, I want to only be able to see what is closest.
If what is closest moves, I want it to switch to what is behind that.

Thanks!

Edit: Essentially, what do I set the Set LineOfSight Range to?
B
5
Posts: 37
Reputation: 299

Post » Wed May 20, 2015 1:54 am

you can use the System Pick Nearest event.. then check the speed or however you determine it is "moving"
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Wed May 20, 2015 1:38 pm

Thank you! What do I enter under "range" for that?
B
5
Posts: 37
Reputation: 299

Post » Wed May 20, 2015 1:50 pm

The pick nearest event/condition doesn't have a range..
When using pick nearest the way described below you can set your range to whatever you want for only the nearest enemy within LOS will be used for the actions.

player has line of sight to enemy
enemy pick nearest to player.x,player.y
> player shoot at enemy
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed May 20, 2015 2:07 pm

I have sprite_3 (my player) has LOS to object angel_01 (enemy) but can't seem to find pick nearest under actions
B
5
Posts: 37
Reputation: 299

Post » Wed May 20, 2015 2:13 pm

It's not an action, it's a condition..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed May 20, 2015 2:14 pm

it's not an action.. its an event. it's under System

it sounds like you need to use it as a "sub-event"

I can't tell what you are trying to do.. but it should be something like this

CHECK the RANGE in a top level event like this:
if range < 200
(add a sub_event of this check) System Pick Nearest sprite etc... then add an action once you pick the nearest sprite...
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Wed May 20, 2015 2:19 pm

jobel wrote:it's not an action.. its an event. it's under System

it sounds like you need to use it as a "sub-event"

I can't tell what you are trying to do.. but it should be something like this

CHECK the RANGE in a top level event like this:
if range < 200
(add a sub_event of this check) System Pick Nearest sprite etc... then add an action once you pick the nearest sprite...


@jobel

it's not a system event or condition, pick nearest is an object event/condition..

so you don't use system pick nearest, but sprite pick nearest to a specific point..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed May 20, 2015 2:22 pm

Image

For pick instances, all I have are
Pick All
Pick by Evaluate
Pick overlapping point
Pick by comparison
Pick nth instance
Pick Random Instance
but no nearest

What I'm trying to do is make it so the angels freeze when the light is on them. However, if one is behind another, in its "shadow," it is free to move around it.
B
5
Posts: 37
Reputation: 299

Post » Wed May 20, 2015 2:29 pm

otaconnor wrote:Image

For pick instances, all I have are
Pick All
Pick by Evaluate
Pick overlapping point
Pick by comparison
Pick nth instance
Pick Random Instance
but no nearest

What I'm trying to do is make it so the angels freeze when the light is on them. However, if one is behind another, in its "shadow," it is free to move around it.


It is not a system event, it's an event of the object..

So: "Angel_01 pick nearest" and not: "system pick nearest.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests