Line-of-sight behaviour problem with 4 directions

Get help using Construct 2

Post » Wed Jan 29, 2014 2:50 pm

So have been looking through tutorials etc trying to get the hang of using Pathfinder to create AI etc.

Come up against a problem - my player and enemy move in 4 directions, so top down but with perspective, like old school Zelda.

I have set my enemy to move using pathfinder and the animations are now correct depending on which way he's travelling but I can't vary the line-of-sight. It always points to the right. I can't use a rotating sprite because of the 4-direction animations...

Anyone know, how can I get my enemy to "look" in the correct direction with LOS?
B
5
Posts: 19
Reputation: 323

Post » Thu Jan 30, 2014 11:33 am

Anyone got any idea?

The line of sight cone is always "looking" to the right whilst my sprite moves / changes direction etc. How can I make the LOS cone relate to the direction the sprite is looking in?
B
5
Posts: 19
Reputation: 323

Post » Thu Jan 30, 2014 11:51 am

Well, the problem is the rotation and movement direction.

One thing you could do is use another object for each enemy.

This object would be a single invisible pixel. You would want to put this pixel in the same Container as the enemy, so each enemy has a pixel linked to him, and when an enemy is picked, the pixel is also picked.

Then, you would have to have the pixel handling the pathfinding, and rotating, instead of the enemy. The enemy would only be pined to the pixel, without rotation. You still handle the rotation of the enemy sprite manually as you do right now. You will also have to transfer the movement function to the pixel, as he is now the one moving.

So now that the pixel moves and not the enemy, if you have the line of sight on the pixel object, it will follow the rotation.

After re-reading what I wrote, I may completly miss your problem, if I misunderstood how you handle the enemy rotation on screen. If that is the case, sharing your capx could help.Guizmus2014-01-30 11:52:41
B
17
S
8
G
4
Posts: 461
Reputation: 6,147

Post » Thu Jan 30, 2014 1:29 pm

That sounds like it might work. So would that be using a container rather than pinning the sprites to each other?

My capx is shared on dropbox but don't have rep to post full link - you should be able to get to it from this partial link though (it's everything after the dropbox.com).

/s/b6w5tqw45t0akhi/LOS%20issue.capx

Appreciate the help.
B
5
Posts: 19
Reputation: 323

Post » Thu Jan 30, 2014 2:09 pm

I can't take a look right now, I'll come back to it later.

Using a container is usefull because :
- if you pick an enemy in an event, you'll pick also the pixel, and the opposite way too
- if you destroy / spawn one, the other will do the same. (you will have to have an event that, on enemy spawn, pins the enemy to the pixel though)
Containers just says that one cannot exist without the other.
B
17
S
8
G
4
Posts: 461
Reputation: 6,147

Post » Tue Apr 01, 2014 7:08 pm

Just wondering if a solution was ever found to this problem?

I'm using the same setup with a player that has the 8 Direction behaviour set to 4 directions, 'Default controls' set to 'No' (I'm using a Gamepad) and 'Set angle' property set to 'No'.

I tried the following and the event 'Has LOS of object' never returns true despite the dummy object changing direction correctly:

1. Insert dummyObject and assign it the 'Line of Sight' behaviour (using default values)
2. In the event sheet, 'For every tick':
2a. 'Set angle' for dummyObject to: player.8Direction.MovingAngle
2b. 'Set position to another object' for dummyObject to 'player' (leaving Image point option as 0)
3. In the event sheet, if dummyObject 'Has LOS to object' where object is 'someGameObject':
3a. 'Set opacity' of 'someGameObject'

Like I said, the dummyObject moves with the player and rotates based on the 4 directions of movement correctly not that it matters since the default value for ConeOfSight is 360 degrees so it doesn't matter about the facing direction.

There are also no solid obstacles between the dummyObject and someGameObject.

Going to try one or two more things, but in the event someone spots a problem or has a solution would really appreciate your comments.
B
5
Posts: 2
Reputation: 229

Post » Tue Apr 01, 2014 8:31 pm

JonathonOgden wrote:Just wondering if a solution was ever found to this problem?

I'm using the same setup with a player that has the 8 Direction behaviour set to 4 directions, 'Default controls' set to 'No' (I'm using a Gamepad) and 'Set angle' property set to 'No'.

I tried the following and the event 'Has LOS of object' never returns true despite the dummy object changing direction correctly:

1. Insert dummyObject and assign it the 'Line of Sight' behaviour (using default values)
2. In the event sheet, 'For every tick':
2a. 'Set angle' for dummyObject to: player.8Direction.MovingAngle
2b. 'Set position to another object' for dummyObject to 'player' (leaving Image point option as 0)
3. In the event sheet, if dummyObject 'Has LOS to object' where object is 'someGameObject':
3a. 'Set opacity' of 'someGameObject'

Like I said, the dummyObject moves with the player and rotates based on the 4 directions of movement correctly not that it matters since the default value for 'Cone of view' is 360 degrees so it doesn't matter about the facing direction.

There are also no solid obstacles between the dummyObject and someGameObject.

Going to try one or two more things, but in the event someone spots a problem or has a solution would really appreciate your comments.


Problem solved.

I had a 'Solid' behaviour on my player which meant that the dummyObject line of sight was always obscured by the player because the 'Line of Sight' behaviour had the 'Obstacles' property set to 'Solids'.
B
5
Posts: 2
Reputation: 229


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest