[Behavior] Grid based sight

Post your completed addons to share with the community

Post » Tue Oct 11, 2011 9:15 am

You can use the Sight behavior expression Tilesize to get the Sight's tilesize which you can also set in the behavior properties. You can use this for cell based calculations e.g.:

round(Mouse.X/Player.Sight.Tilesize) * Player.Sight.Tilesize

Grid expressions:

Sight: Grid

O Height: Get the height in cells of the field of view grid.
O Offset: (used but not useful I think)
O Radius: Get the sight radius.
O Tilesize: Get the grids tilesize.
O Width: Get the width in cells of the field of view grid.
B
21
S
7
G
2
Posts: 185
Reputation: 3,280

Post » Sun Oct 16, 2011 1:05 pm

For some reason when I change the radius, nothing happens. Any ideas why?
Oh, and I got it working with your last posts :)
B
40
S
8
G
6
Posts: 61
Reputation: 5,941

Post » Sun Oct 16, 2011 10:26 pm

[QUOTE=bowiz2] For some reason when I change the radius, nothing happens. Any ideas why?
Oh, and I got it working with your last posts :)[/QUOTE]

How and what are you setting the radius to?
B
21
S
7
G
2
Posts: 185
Reputation: 3,280

Post » Mon Oct 17, 2011 10:54 am

B
40
S
8
G
6
Posts: 61
Reputation: 5,941

Post » Mon Oct 17, 2011 4:45 pm

[QUOTE=00Rez] [QUOTE=bowiz2] For some reason when I change the radius, nothing happens. Any ideas why?
Oh, and I got it working with your last posts :)[/QUOTE]

How and what are you setting the radius to?[/QUOTE]



Toggle disable this then change the radius to 10 and preview then change it back to 5 and preview. The way you set opacity is the problem no matter how big the radius is the opacity is reduced at a set distance.
B
21
S
7
G
2
Posts: 185
Reputation: 3,280

Post » Tue Oct 18, 2011 12:04 am

When I disable it the radius gets really big, more or less the way I want it, but I didn't get what you said about the set opacity thing. I just copied from the example file. What I understood is that code makes it so that the opacity is set in relevance to its distance from the light source, but only up to a certain distance. Is this right? If so, how can I change what the restraint is?
B
40
S
8
G
6
Posts: 61
Reputation: 5,941

Post » Tue Oct 18, 2011 12:09 pm

[QUOTE=bowiz2] When I disable it the radius gets really big, more or less the way I want it, but I didn't get what you said about the set opacity thing. I just copied from the example file. What I understood is that code makes it so that the opacity is set in relevance to its distance from the light source, but only up to a certain distance. Is this right? If so, how can I change what the restraint is?[/QUOTE]

The equation I used for the opacity was a quick implementation.

The radius say 5 is multiplied by the tile size which is default 32. This is the maximum distance at which the opacity would be 100 or 0 depending on how you blend the LightCell/Shadow. You need to gradually decrease/increase this as the distance decreases back to the centre. Plus a realistic light has more of a drop off than a linear reduction in intensity. There is a bit of math involved in producing a realistic light. Experiment.

Quick and easy way: min(Distance from light to shadow cell / (Radius * Tilesize), 1) this produces a number between 0 and 1. To invert take this number from 1 then multiply by 100 to get a value you can assign to the opacity setting for the lightcell/shadow objects.

Make sure you snap to the grid when placing the objects or it won't look right.
B
21
S
7
G
2
Posts: 185
Reputation: 3,280

Post » Tue Oct 18, 2011 1:34 pm

I managed to get it to work somewhat, but instead of being lightest at the center, its darkest. How do I invert it? I think you explained it in your last post, but I still don't really get it. Can you try and explain it as if your explaining to an imbecile?
Here is the code for the opacity:
Lightcell--->Set Opacity To min(distance(Sun.X,Sun.Y,Sun.Sight.CurPixelX,Sun.Sight.CurPixelY)/ (10 * 32), 1)*100
B
40
S
8
G
6
Posts: 61
Reputation: 5,941

Post » Tue Oct 18, 2011 2:19 pm

[QUOTE=bowiz2] I managed to get it to work somewhat, but instead of being lightest at the center, its darkest. How do I invert it? I think you explained it in your last post, but I still don't really get it. Can you try and explain it as if your explaining to an imbecile?
Here is the code for the opacity:
Lightcell--->Set Opacity To min(distance(Sun.X,Sun.Y,Sun.Sight.CurPixelX,Sun.Sight.CurPixelY)/ (10 * 32), 1)*100[/QUOTE]

Lightcell--->Set Opacity To 1 - (min(distance(Sun.X,Sun.Y,Sun.Sight.CurPixelX,Sun.Sight.CurPixelY)/ (Sun.Sight.Radius * Sun.Sight.Tilesize), 1)) * 100

The 1 - inverts the opacity. The Sun.Sight.Radius and Sun.Sight.Tilesize are expressions and if you put them in you don't have to worry about changing them as it will automatically update.
B
21
S
7
G
2
Posts: 185
Reputation: 3,280

Post » Tue Oct 18, 2011 3:30 pm

That didn't work for me, but it doesn't matter. I found that if you change from Destination Out to Destination In (on the lightcell of course) it works perfectly fine.
I know I have a lot of questions, but this thing has a ton of potential so I'm really trying to get the most out of it.
So my next question is: How can you change the "core" size of the light? By default it seems that the light starts from a single block (and its full strength there) and gets gradually dimmer. The core is that single full brightness block. So how can I change it to be instead of 1X1 to be (for example) a 3X3 core?
B
40
S
8
G
6
Posts: 61
Reputation: 5,941

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests