NPC Movement

117 views
Skip to first unread message

conor....@gmail.com

unread,
Oct 22, 2014, 7:36:36 PM10/22/14
to puzzle...@googlegroups.com
Does anyone know if it is possible to make an NPC move in a repeating pattern (up and down, left to right) or just in a straight line WITHOUT being influenced by the player or any obstacles? I'm attempting to make a stealth based puzzle game but I don't want my guards running all over with RandomDir command.

James T. Perconti

unread,
Oct 22, 2014, 11:41:28 PM10/22/14
to conor....@gmail.com, puzzle...@googlegroups.com
Sure! It might take a lot of boilerplate depending on how complex the pattern is, but I think the easiest way is just to make several objects to represent different stages of the NPC's movement pattern. Here's a really simple example game I hacked up; have a look at the source: http://www.puzzlescript.net/play.html?p=1a306162b61551b1916a

There's a lot that could be done for more sophisticated movement. I avoided the problem of having the player get in the way and disrupt the movement pattern by having you just get stuck if you stand next to an NPC. Feel free to ask if you want suggestions for how to implement particular behaviors.
  --Jamie Perconti

On Wed, Oct 22, 2014 at 7:36 PM, <conor....@gmail.com> wrote:
Does anyone know if it is possible to make an NPC move in a repeating pattern (up and down, left to right) or just in a straight line WITHOUT being influenced by the player or any obstacles? I'm attempting to make a stealth based puzzle game but I don't want my guards running all over with RandomDir command.

--
You received this message because you are subscribed to the Google Groups "PuzzleScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puzzlescript...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Connorses _

unread,
Oct 22, 2014, 11:48:18 PM10/22/14
to puzzle...@googlegroups.com, conor....@gmail.com
Yes, you'll want to make multiple objects though, such as guardLeft and guardRight, I'll make a quick example. It's pretty simple. They basically switch whenever they're facing a wall. Putting directions like "left" or "right" before a rule makes sure the rule only applies to one direction.

http://www.puzzlescript.net/editor.html?hack=01f42279a19210c4a35c

(I probably had way too much fun making this)

Connorses _

unread,
Oct 22, 2014, 11:49:42 PM10/22/14
to puzzle...@googlegroups.com, conor....@gmail.com
Wow, I guess Jamie beat me to it.


On Wednesday, October 22, 2014 5:36:36 PM UTC-6, conor....@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages