Line of sight (sort of)

Im making a game based off the night cage board game. In which there are tiles but if you move to the side and lose direct line of sight or if one of the tiles walls are blocking the (adjacent) line of sight they disappear and are randomized upon reappearance

Im pretty much stumped ive tried everything i have thought of but it doesn’t work (i don’t remember exactly what ive tried)

Basically i would like help making tiles that arent in adjacent view disappear and as its turn based stop it from passing through walls (note the sides of the map are like pacman it just goes to the other side) any help is greatly appreciated

these blocks tell you what sprite the line of sight in the sprites current direction hits first:

scripts

untitled script pic (9)
you could remove the WARP block to make it slower, or add a check for the edge:

I would recommend using the ray length to __ block. It's in sensing, and ray length is an option under distance to __.

Here is a project that uses that block. The player points in the direction of the mouse-cursor. If the player "sees" the object, then a line from the player to the object shows up.
Snap! example line of sight (berkeley.edu)

the problem with the ray length TO block is that the sprite can "see" objects through other sprites. I don't think thats what @1042470 is looking for.

Here's a way to do it using the ray length

nice!
I think this is faster than my version, since it doesn't create clones

Thank you all! Ill try them all out

My personal solution is


(I think it is actually less than or equal to)
untitled script pic 21

A couple problems, first, if neither the wall nor the object are in the line of sight from the Sprite, the block will report true, when neither Sprite can actually be seen. A fix would be to add POINT TOWARDS target above the report bock.

Second, the custom ray length block should report -1 if the Sprite is not seen, to be consistent with the primitive.

Then make it normal and not equal to

It also shouldn’t matter because the ray length would report -1 no matter what even if it’s true

that would work.

I was saying that in the custom block, the bottom report block should report -1 instead of nothing.

Hi, is there a way to have this script accept a, ask for my children or just a list of clones?

Yeah, just set the sprites variable to a different list of sprites, e.g. my children (clones are technically sprites).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.