You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this is the right category but it made the most sense to me. So in my project I have a tiled map and I want to remove a specific "block" tile in a "blocks" layer. I already have the logic set in place and it works but I run into an issue where the tile is still visually there but isn't blocking the shot.
foreach (Vector2 blockPosition in TileGraph.BlockPositions)
{
// Convert block position to tile indices
Point tilePosition = new Point((int)(blockPosition.X), (int)(blockPosition.Y));
// Calculate block world position
Vector2 blockWorldPosition = blockPosition * 16;
// Check for collision between missile and block
Rectangle missileBounds = GetBound();
Rectangle blockBounds = new Rectangle((int)blockWorldPosition.X, (int)blockWorldPosition.Y, _tiledMap.TileWidth, _tiledMap.TileHeight);
if (missileBounds.Intersects(blockBounds))
{
Debug.WriteLine("RUN");
// Destroy the block position
TileGraph.BlockPositions.Remove(blockPosition);
// Remove the tile from the layer
_blockLayer.RemoveTile((ushort)tilePosition.X, (ushort)tilePosition.Y);
Debug.WriteLine($"{(ushort)tilePosition.X}, {(ushort)tilePosition.Y}");
// Destroy the missile
GameObjectCollection.DeInstantiate(this);
break;
}
}
(The wood is supposed to be a block)
As you can see it's still visually there but not blocking any shots. I debugged to make sure that it's the right tile and making sure the bounds for the missile is correct and it was so I'm really confused
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm not sure if this is the right category but it made the most sense to me. So in my project I have a tiled map and I want to remove a specific "block" tile in a "blocks" layer. I already have the logic set in place and it works but I run into an issue where the tile is still visually there but isn't blocking the shot.
(The wood is supposed to be a block)
As you can see it's still visually there but not blocking any shots. I debugged to make sure that it's the right tile and making sure the bounds for the missile is correct and it was so I'm really confused
Beta Was this translation helpful? Give feedback.
All reactions