Checking for actor of group "tiles"

darrigaz

  • Posts: 124
I'm doing some basic pathfinding using raycasting.
I cast a ray from an enemy to the player and if the returned list has the words "Terrain" in it then I assume the enemy can't see the player.

This works fine, however it's doing lots of runtime string comparison which is really slow and noticeably causes framerate drops in levels with more enemies and more complex pathfinding.

Is there a way of checking the return values of the raycast api that doesn't rely on string comparison? Such as checking for actors of type "tiles" rather than checking for the terrain string?

merrak

  • *
  • Posts: 2644
There are the "group of (actor)" and "type of (actor)" blocks in Actors -> Properties

darrigaz

  • Posts: 124
Tried those and they don't work.

Sadly the raycast api seems to return actors (for tiles "Actor 100000000,Terrain") and there is no terrain option in the type of actor blocks.

Basically I want to do this but without the slow text conversion..

darrigaz

  • Posts: 124
Maybe i need to check through each actor in the list to see if it is the relevant type using a "for each item in list" loop"?

merrak

  • *
  • Posts: 2644
This is what I'm using to check for collisions against tiles (image attached) in the arc version of raycast. The generated code from the first screenshot is below. Maybe what you're checking for collisions against has a different actor group number?

Code: [Select]
public static function _customBlock_EAI_collidable(__a:Actor):Bool
{
/* Quick function to return groups of actors the enemy should avoid hitting */
return ((__a.getGroup() == getActorGroup(1)) || (__a.getGroup() == getActorGroup(8)));
}

Edit:
Here's the print statement from a log of the code above executing. It shows a tile registering as "Terrain"

Code: [Select]
[haxelib] Design_232_232_EnemyLauncherAI.hx:247: Collision with [Actor 100000000,Terrain] detected... try another angle.