On Grid map to caculat Explosion range that could be block

Godot Version

4.x

Question

i want to creat Conical magic or circular magic. it can be caculat Scope of influence on grid map and could be blocked. what should i do?

If I understand correctly, you want to make a conical explosion. The conical explosion will fire in some direction. The objects that are in the path of the explosion might block it and shield the objects behind it.

My suggestion is:
Have an Area (idk if this is 2d or 3d) in the shape of a cone. Have the area detect all objects in the cone. For each object, fire a raycast from the origin point to the target object. The objects that are hit by the raycast are the ones that are hit by the explosion. The objects that are not hit by the raycast are shielded by something in front of it.

This is quite simple, since some objects may partially overlap, so you’d need more raycasts or advanced math to do precise calculations.

1 Like

good idea!
If i want to change the floor that be affected at the same time,how it works?

I can’t be very specific since I don’t use grid map and don’t know much about it.

I think the gridmap has one collider so you can’t pick one specific block so you would need calculations. Calculate the outer positions of the area. If you take 3 points in a cone, you can make a triangle. This isn’t exactly a cone but it’s a start. Then, for each block in the grid, check if it’s position falls within the three coordinates.

If the gridmap does have a collider per block you can just detect the affected blocks using the area.

thanks for you suggests, i have a plan ,i can use ShapeCast2D to find all target ,and shot to every grid.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.