[SOLVED] Ignoring Objects on a Layer

For questions about using Classic.

Post » Thu Jul 28, 2011 8:28 pm

Is it possible to instruct an object to ignore all objects on a specific layer? Specifically, I want a line-of-sight behavior to ignore all solids on a layer different than its own.SAAj2011-07-30 01:53:27
B
4
S
1
G
2
Posts: 39
Reputation: 1,028

Post » Thu Jul 28, 2011 11:21 pm

Most objects have a condition "Is on layer"

If an object is picked you can use an inverted "Is on layer" to exclude the ones from the layer you want to be ignored.

EDIT: Didn't read correctly. No need for inverting. Just test for the same layer with the normal "Is on layer"tulamide2011-07-28 23:24:22
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Fri Jul 29, 2011 9:25 am

I'm not sure how to apply that to the problem I have. I have two objects with line-of-sight behavior (LOS1 and LOS2), and two objects with the solid attribute (S1 and S2). I want LOS1 to treat both S1 and S2 as obstacles, but I want LOS2 to treat only S2 as an obstacle.

I want to avoid using custom obstacles, leaving both line-of-sight behaviors on 'solid'. I want to put S1 and S2 on different layers and tell LOS2 to ignore S1 (perhaps to ignore the entire layer it's on).

The way I currently have it set up, S1 is not directly targeted at all. LOS1 and LOS2 are both targeting an object behind S1, so I'm not sure how to get LOS2 to ignore S1 or the layer it's on.
B
4
S
1
G
2
Posts: 39
Reputation: 1,028

Post » Fri Jul 29, 2011 9:52 am

Pretty much how tulamide said.
When you test LOS1, you put no other condition. So LOS1 should react to any object (whatever layer it is on).

When you test LOS2, you add another condition, being "Is on layer" (See Tulamide's post). This way, LOS2 will only react to objects on its same layer.
LOS2 needs to be on a different layer than S1, and S2 needs to be on the same layer.

If you're still stuck, consider posting a .cap with the setup you described that will help give you back the proper code.Kyatric2011-07-29 09:53:30
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Fri Jul 29, 2011 3:25 pm

If your testing for "solid", then telling it not to test for solid on a layer wont do. Its either all in, or all out when comparing an attribute.
However you can test if an object is on a layer, and then set the collision mode for those objects to none.
Image Image
B
161
S
48
G
90
Posts: 7,350
Reputation: 66,755

Post » Fri Jul 29, 2011 7:29 pm

http://www.mediafire.com/?jbbh122xabr7bu8

I've got LOS2 and S2 on a different layer, but I can't seem to get LOS2 to acknowledge the target and ignore S1.SAAj2011-07-29 19:29:51
B
4
S
1
G
2
Posts: 39
Reputation: 1,028

Post » Fri Jul 29, 2011 9:07 pm

Ah, now I see what you are aiming for. There is a simpler way to achieve this.

In the LOS behavior, set Obstacles to "Custom"
In the event sheet, whereever needed, use the behaviors actions "Clear obstacles" and "Add obstacle" to build your own list of objects to be treated as obstacles.

Download: http://www.mediafire.com/file/f1rq4dgb9g64p7g/LOScustom.cap
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Fri Jul 29, 2011 10:50 pm

That's the first thing I tried. Unfortunately, custom LOS settings kill the framerate after the application runs for a minute or two. I have no idea why this occurs, but I know my machine isn't the only one that experiences this issue. Here's the original .cap running with custom LOS:

http://www.mediafire.com/?rdb1iwxqt4nt30q

It'll run at a healthy 70+ fps for about half a minute, then start dropping into the 30s, and finally plateau at below 10 fps. This may not be an issue on fast machines, but this is meant to be a simple, 16-bit-style game. If my machine, which can just barely run Orange Box, can't handle it, a lot of my target audience won't be able to either.

That's why I need to figure out how to bypass the need for custom LOS. I was hoping there's a way to ignore an entire layer, or something to that effect.
B
4
S
1
G
2
Posts: 39
Reputation: 1,028

Post » Sat Jul 30, 2011 12:38 am

It's not the LOS behavior but an error you made in the cap. You will get a more detailed answer and the corrected cap soon
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sat Jul 30, 2011 12:40 am

Tested your cap out with Tulimide in chat, and we found a solution, as well as a bug.

It seems you were constantly adding the boundaries to the los obstacles, and thats most probably what was causing the fps drop.
So if you look at event 28 you'll see the always event, just change that to a trigger once while true, and drag your sub-event on its own. It doesn't need the always.
Now that will fix the fps, but Tulimide found a real bug with los picking multiple instances, and while it doesn't seem to harm the preview it drives the debugger crazy, and if you try to click on one of the "extra" instance's reference it will crash the preview. So I would say its probably not a good idea at this time to add an object that has multiple instances to the los behaviors "add obstacle". Instead you can place the object you know will have multiple instances into a family and add that family to your "add obstacle" event.
Like so:
trigger once while true-> los add obstacle family.black
Fixed cap in link.
Image Image
B
161
S
48
G
90
Posts: 7,350
Reputation: 66,755

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests