The Gaming Industry

02
Aug 2020

Is there a more efficient way to check nearby tile locations for colliders?

So am building a turn based game and something I need to be able to track is what nearby tiles are open so I currently have this code:

var selfPosition = gameObject.transform.position;
var availableNearbyPositions = new HashSet<Vector3>();
var hits = new RaycastHit2D[1];
var layerMask = LayerMask.GetMask(LayerName.CHARACTER) + LayerMask.GetMask(LayerName.GROUND);
  
var scanRadius = 3;

for (int x = -scanRadius; x <= scanRadius; x++) {
  for (

Powered by WPeMatico

Tags are not defined
Comments are closed.