Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Sight Range (Events hurt my brain :P) [Resolved]

Okay, so I have a scene in my game where after a switch is on, several guard NPCs will move in a specified pattern, and when the player is 5 tiles away or less in the direction they're facing, witty bantering (Show Text: We caught you go die mwahahhah etc. etc.) and then it displays a gameover graphic. I think I understand most of it, but the actual sight range event system has me stumped.
Any help would be appreciated. :smile:
 
Hmmm...so this is like the classic guard minigames in Zelda games? (like Ocarina of time) If so, I think this might help. It allows events to see in front of them. However, I'm not sure if it's in a straight line, or a semicircle. Even if it is a semicircle, however, I think you can modify it so that it only sees in a straight line.

Hope it helps! (By the way, if you use it, credit Monsta)
 
For right and up, did you change it to >= -5?  It has to be greater than and negative because of the subtraction properties.

By the way, Doctor, thank you!  I was just trying to do this and I was failing.
 
I never bothered to set right because he only walks up and down, but yes, it is greater than or equal to with a negative. Should I post up a screenshot with the event code?
 
In the Conditional Branch where the enemy's facing up, change
Code:
@>Conditional Branch: Variable 27 >= -5
to
Code:
@>Conditional Branch: Variable 27 <= 5

Also, I think you might want to nest that in another conditional branch that checks if variable 27 >= 0 (and repeat for all directions), because otherwise if you're behind the enemy he can still see you.
 
Ah, I found the problem!  When you just have <=, it can be negative as well, which means they can see behind themselves.  You have to add a >= 0 conditional branch in there.  Anyway, I created a quick demo.  Pull the switch to change the monster's direction.  I changed some of the variable operations so that you've always got <=2 and >=0.  I hope it helps. :thumb:

http://www.mediafire.com/?plnanljzqyd
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top