No LineofSight outside walls

0 favourites
  • 11 posts
From the Asset Store
Weather Sounds contains 132 sounds from them 64 seamless loops
  • Hey guys!

    I have an enemy with a line of sight view which wanders around and look for the player. Is it possible to hide parts of the sprite outside/behind walls? Or is there any other way to do his?

    Here is a screen and you can see its a static sprite pinned to the enemy.

    i.imgur.com/kq8CY8Z_d.jpg

  • Thank you very much! That example looks awesome though I don't get it to work correctly. I copied over the the shadow light from your example and gave the walls the shadowcaster. That's what it looks like right now

    i.imgur.com/8nr4wpe.png

    Looks like the destination out is not working.

    Edit: FOV Sprite and Shadow caster are on the same layer.

  • Check blend modes for all objects, their z-order (ShadowLight should be above the FOV sprite). Also make sure to turn "Force own texture=On" in layer properties.

  • Check blend modes for all objects, their z-order (ShadowLight should be above the FOV sprite). Also make sure to turn "Force own texture=On" in layer properties.

    You are the man!

    https://i.imgur.com/chIre9g.png

    Just need to check how hard the hit is on cpu when on mobile and using more enemies!

    But thank you very much this is really cool!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • One last question. Does the "Player overlapping EnemyFOV" work with the shadowcaster any way? Or does it make more sense to use the LOS behaviour for detection?

  • You need to use LOS.

    Although it looks like FOV sprite is blocked by walls, but in fact it isn't. So "overlapping FOV" will not work correctly if there is a wall between the player and the enemy.

  • The "FOV" object exists, even if it is not displayed. So, in your last screenshot, if an object was in the room where you don't see the "vision cone", it still would trigger the event, given the collision polygon is properly set up.

    LOS would not, has it is out of sight, behind a wall.

    The hit for using and forcing the own texture is minimal on the CPU since this is a webGL rendering thing that acts on the GPU.

    The requirement for it to work is that your device supports webGL and does not fall back to Canvas2D.

  • Alright thanks both on clearing things up! I've added the LOS and it works great. Thank you both for the nice help!

  • I have one problem left with your example dop2000

    When using multiple enemies with fov sprites then on places where one enemy has no visible fov (behind a wall for example) I can also not see other enemies which are at that place.

    Don't know if you understand but I don't know how to describe it.

  • Hmm, I don't know.. You might need to place each enemy+FOV+shadowlight on a separate layer. Say, reserve 10 layers for that and spawn new enemy on an unoccupied layer.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)