Treating an Active as a Flashlight

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hello,

    In my game (Which is in a top-down view similar to older Zelda titles), there are stealth missions where players have to avoid an enemy's line of sight. This is depicted in the game as a flashlight effect of sorts. If the flashlight active overlaps the player, they get caught. The problem I have though, is that it doesn't act like a real flashlight would. When light bounces off a wall for instance, it distorts. At the moment, I have the active changing size constantly, as I am detecting when it overlaps a wall or obstacle and making it smaller when it does, then slowly returning it to normal size when it's not overlapping.


    I have come across a few Please login to see this link. that suggested using overlay redux to achieve this effect, but I have been unable to make that work for multiple enemies on screen at the same time. It also seems that I'm unable to create the flashlight effect without a dark background, although this could be entirely due to my inexperience with overlay redux. Furthermore, I'm unsure I could use this to detect overlaps of the player and trigger the game over I would need.


    Are there any alternatives to give multiple enemies a realistic "flashlight" effect in fusion? Specifically one that could trigger other events when the flashlight overlaps the player? Any ideas are appreciated!

  • A flashlight (aka "shadowcasting") effect is actually very tricky to pull off - especially with multiple light sources (which is also likely to make it slow).
    Please login to see this link.
    Please login to see this link.

    You'll note that the best stealth games, like "Commandos: Behind Enemy Lines", "Shadow Tactics: Blades of the Shogun" and "Desperados: Wanted Dead or Alive" only show the viewcone of one enemy at a time, and are much better for it.

    Also, you'll have to handle the line-of-sight calculation for enemies separately. You'd use a ForEach loop to check for a clear line-of-sight between each enemy and the player, one at a time. The standard approach is to use a 1px detector object, scale it along one axis (width or height, but not both) to the distance between the enemy and the player, and then rotate it to the angle between them (that draws a line between them). Then just check if the detector is overlapping an obstacle or anything else that would block line-of-sight.

  • A flashlight (aka "shadowcasting") effect is actually very tricky to pull off - especially with multiple light sources (which is also likely to make it slow).
    Please login to see this link.
    Please login to see this link.

    You'll note that the best stealth games, like "Commandos: Behind Enemy Lines", "Shadow Tactics: Blades of the Shogun" and "Desperados: Wanted Dead or Alive" only show the viewcone of one enemy at a time, and are much better for it.

    Also, you'll have to handle the line-of-sight calculation for enemies separately. You'd use a ForEach loop to check for a clear line-of-sight between each enemy and the player, one at a time. The standard approach is to use a 1px detector object, scale it along one axis (width or height, but not both) to the distance between the enemy and the player, and then rotate it to the angle between them (that draws a line between them). Then just check if the detector is overlapping an obstacle or anything else that would block line-of-sight.

    I see, so it would seem that I need to make a compromise either way. Maybe it would be better for me not to display it as some kind of flashlight then. I don't want that slow down after all :P

    Thanks MuddyMole, I will use your method for line of sight. Sounds better than what I'm currently doing!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!