- Joined
- Aug 15, 2013
- Messages
- 72
- Reaction score
- 32
- First Language
- English
- Primarily Uses
- RMMV
Hi all!
I'm making a stealth script because there wasn't any that fit my particular needs. The "does the NPC detect the player" part is all taking place in common events because I'm too lazy to make an actual script.
As is usual with game development, vision is three checks: a distance check, an angle check, and a raycast check (in that order, due to how expensive each operation is). If one doesn't pass, you cancel out. If it does, you move onto the next step.
I've got the first two implemented, but it's the last one that I'm struggling with a little. This is my current thinking: the raycast will go from the npc event to the player event. Picture a line drawn through every single square between the two. If any of those squares are "not walkable", the raycast check fails.

What do people think of this? Fortunately it won't be too many squares due to the distance check previously. I still need to think of the math of "getting every square in a line between two squares", as well as actually learn how to get the collision details from a map through JavaScript. If anyone has any knowledge of these, I would love to hear it! (I come from a Unity background, so my knowledge of interacting with RPG Maker's internals is still very fuzzy).
I'm making a stealth script because there wasn't any that fit my particular needs. The "does the NPC detect the player" part is all taking place in common events because I'm too lazy to make an actual script.
As is usual with game development, vision is three checks: a distance check, an angle check, and a raycast check (in that order, due to how expensive each operation is). If one doesn't pass, you cancel out. If it does, you move onto the next step.
I've got the first two implemented, but it's the last one that I'm struggling with a little. This is my current thinking: the raycast will go from the npc event to the player event. Picture a line drawn through every single square between the two. If any of those squares are "not walkable", the raycast check fails.

What do people think of this? Fortunately it won't be too many squares due to the distance check previously. I still need to think of the math of "getting every square in a line between two squares", as well as actually learn how to get the collision details from a map through JavaScript. If anyone has any knowledge of these, I would love to hear it! (I come from a Unity background, so my knowledge of interacting with RPG Maker's internals is still very fuzzy).



