playMaker

Author Topic: Simple Looping Movement  (Read 1423 times)

EpicChowder 619

  • Playmaker Newbie
  • *
  • Posts: 13
Simple Looping Movement
« on: February 02, 2015, 06:08:54 AM »
This is pretty simple stuff but i'd like to know what would be the best FSM action for simple movement that loops. In more detail, ive got an enemy cube that resets the level when you touch it and i'd like for the cube to move around a trigger as if to defend it. I know that there are lots of ways to do this but i'd like to know which is the best, if possible.

richardh

  • Junior Playmaker
  • **
  • Posts: 97
Re: Simple Looping Movement
« Reply #1 on: February 02, 2015, 06:27:09 AM »
I created a very simple AI FSM which did something similar.
I set up a ray-cast that looks for any item 50 units ahead (z axis)
at run time, the cube would rotate with the ray-cast firing on the Z
when it hit something. I would set a 'move toward' event with a finish of say 1.
on finish, the cube would rotate again and look for the next ray-cast hit and move toward that... etc.

The ray-cast would also be looking for the 'Player' and on seeing the player then the cube would be instructed to 'attack'.

I had to setup a system so that if the ray-cast hits NOTHING then he will rotate a bit more.
I had to tweak it and fine tune to get around problems like finding NOTHING on 360 degrees and a few other niggles but i got a good simple AI system working after a bit.

You could have an area marked out with invisible cube markers and have your cube move to the first/2nd/3rd etc. on a loop. But I wanted a random move system.
The way I did it (above) results in an enemy being able to move over my whole area in a totally random way. He moves around while also keeping watch for the player. He'll run after the player and if he reaches the player he will attack. If the player runs and gets out of sight (hides) then the enemy will keep looking for the player for a bit and after a time will give up and revert to his random movement.