Line of Sight - Not working in most simple way...

Get help using Construct 2

Post » Sat Jul 30, 2016 3:48 am

I had this working and then did something which started causing awkward behaviour, so I deleted all of my line of sight code and started over. I am at a very simple form of line of sight and its not working and its blowing my mind.

Obstacles: Solids
Range: 400
Cone of View: 360
Use Collision Cells: Yes

Event:
Enemy has LineOfSight to Soldier -> Set SeesEnemy 1

Thats it....and its not working at all.

The enemy spawns on the right side of the window, uses pathfind to find a path to a random Solider. The objective is that when it triggers lineofsight to soldier I will change the speed to make the enemy stop. (it was working before without issue). On Create the enemy finds the path, moves along the path, but when its within line of site range it does nothing, just continues to the Soldier and stops when it arrives, never triggers lineofsight at all. I am absolutely baffled.

Quick Edit. I have the Soliders using a line of sight behaviour as well, and they trigger line of sight fine, and throw squares at the enemy when they are within range. So line of sight does work with Soliders, but not Enemy even in the most simplest form.
B
9
S
3
Posts: 50
Reputation: 804

Post » Sat Jul 30, 2016 4:01 am

I figured it out, but it doesn't seem right.

I disabled Solid Behavious on the Soldier and it started getting LOS to the Solider Correctly. However the Enemy has solid behaviour and Soldiers are able to line of sight them just fine. Something is wrong or I am missing something extremely obvious.
B
9
S
3
Posts: 50
Reputation: 804

Post » Sat Jul 30, 2016 4:07 am

Figured it out again even though I still think it shouldn't behave this way. Solider LOS obstacles was set to Custom, while Enemy was set to Solid.

So Enemy cannot see Soldier when LOS Obstacle on Enemy is set to Solid, and Soldier has Solid Behaviour Enabled.

Is it because Enemy is seeing Soldier as an Obstacle instead of a Target, even though I have it specifically looking for that Soldier Object?
B
9
S
3
Posts: 50
Reputation: 804

Post » Sat Jul 30, 2016 12:27 pm

This is true. If you set an object as obstacle, it can not see to a point into that object.

If you set an object as obstacle, you can not find a path to a point into its collission polygones too.

Remains the question, why solids ? Is it needed ?

I try to post you a kind of solution later today, with them all beeing solids.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Jul 30, 2016 3:15 pm

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Jul 30, 2016 8:37 pm

@99Instances2Go thank you very much, it is helpful beyond words. I am curious on how you would solve the overlapping problem now? So they make it to destination but all pile up and look like one object, this is not something that will be good at all in the type of game I am working on. I tried doing is overlapping at offset and such to move the object down 10 pixels or up 10 pixels if it sees an overlap but it seems to not work right. Push out from Solid (rex behaviour plugin) just doesn't look to natural it looks like they are literally pushing the object which is no good.

There will potentially be 1-20 enemy on the map at a time, and they all need to have a line of site so when they throw rocks its not unrealistically going through the body of the enemy in front of them like its a magic rock.
B
9
S
3
Posts: 50
Reputation: 804

Post » Sat Jul 30, 2016 9:19 pm

Understood, and that is difficult. Wel for me it is. I come back to this.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jul 31, 2016 3:08 am

I made a custom "flocking" system in CC to stop characters from stacking on each other. If i remember correctly I made a helper/detector sprite that was slightly bigger than the characters and it would be set to the position of each character always. If the detector was overlapping another character, then he would stop moving -> else he will move to the destination. Maybe something like this will work for you as well?

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Sun Jul 31, 2016 3:24 am

I just changed the way the game is viewed instead of direct top down its more isometric looking now. This allows for z order to be used so objects/characters don't appear to be overlapping as bad.
B
9
S
3
Posts: 50
Reputation: 804


Return to How do I....?

Who is online

Users browsing this forum: David181, OBLIVION, senecaa and 17 guests