Line of Sight question

For questions about using Classic.

Post » Thu Aug 18, 2011 6:59 am

How do you get line of sight to work? I'm trying to change the colour of a tile when it's in sight, but it seems to randomly change the colour of every single tile (regardless of whether it's in sight or not).


My code:



My cap:
http://dl.dropbox.com/u/1024727/caps/lineofsight.capalspal2011-08-18 07:00:31
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Thu Aug 18, 2011 7:13 am

Main issue is needing a 'for each' on the land and having the line of sight events as subevents.

This improves it a lot, but it still flashes on some tiles when moving around.



B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Thu Aug 18, 2011 8:03 am

Thanks, that works well. Pity you have to use "for each" though, with hundreds of tiles it slows it down a bit.
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Thu Aug 18, 2011 10:29 am

Have you adjusted the range etc?
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Thu Aug 18, 2011 1:26 pm

A general word about LOS:
The line of sight behavior isn't designed well for use with multiple-instances-objects.

For each loop:
The for each object loop shouldn't slow it down noticable, if at all. An action with a multiple-instances-object will loop through the instances anyway.
Something like
+ land: Value 'somevar' Equal to 1
-> land: Set filter to somecolor
will execute at the same speed than
+ For each land
++ land: Value 'somevar' Equal to 1
--> land: Set filter to somecolor
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Thu Aug 18, 2011 1:59 pm

Is there an easy way to make my own Line of sight thing then? (doesn't seem to work well with angled objects, especially isometric tiles)
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Thu Aug 18, 2011 2:54 pm

Line of sight is pretty much straight-forward, you can always replicate it with events or python.

Have a look at this thread and scroll to my "cone of view" example (cap included):
http://www.scirra.com/forum/solved-custom-lineofsight-issue_topic43661.html?KW=
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Fri Aug 19, 2011 3:40 am

Thanks I'll look into it.
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests

cron