control code (when out of range of or path obstructed toward player) If (!los.obstructedView(this, pursued, Walltest1.class, Walltest2.class)) Pursue() // replace with appropriate code or method call If (pursued != null & pursued.getWorld() != null) Pursued = (Actor)getObjectsInRange(800, Player_Test1.class).get(0) RandomMovement() // replace with appropriate code or method call If (getObjectsInRange(800, Player_Test1.class).isEmpty()) If (pursued != null & pursued.getWorld() = null) Private SimpleTimer timer = new SimpleTimer() The second mechanic that I want to use is that if the player line of sight becomes obstructed during the pursue method the enemy will move forward for x amount of seconds which if during the forward movement if the player is within range and has no objects obstructing its line of sight it will pursue the player, else the enemy will proceed to do randomMovement method.Īlso I tried to add some classes to which would be considered obstructions however the Enemy AI ignores those walls and proceeds to pursue the player regardless of there being a wall class there. Well actually there are two things that I want the enemy class to do which involve line of sight being obstructed one of them being that as you said for when line of sight is obstructed the enemy will execute the randomMovement method. If you want that the enemy move randomly, you might just try removing the 'obstructedMovement' method and changing the call to it at line 64 to 'randomMovement'. It should only contain the code for the actions of the enemy when we already know that the view is obstructed. Danpost wrote.For the other error, there should not be any line of sight checking in the 'obstructedMovement' method.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |