Programming: Is the blast radius affected by objects?
A bomb explodes and everyone within its radius dies, but if you're behind a wall, you shouldn't take any damage. Unfortunately, I have no idea how to program this. I'm using Godot with C#/GDScript (I use both).
Do you have any idea how to implement something like this?
Thanks for helpful answers
General logic should look
Note that you do not make unnecessary checks here per frame and instead you should use zb events or something temporary.
Your question should actually be whether it is 2d/3d.
My time with Godot and Unity is unfortunately too long since I can say this now, but in the Doku to collision you will surely find a solution for the individual steps.
Alternatively, you could also define safe zones on the map if, in the setting, the bomb has an influence almost everywhere on the map, but there is no information. However, if my second proposal for a solution were to be found, it would be very important for the scenario. This is suitable if there are only little safe zones and otherwise so many objects that such line of sight checks would be intense to performance.
I have a simple idea. That the bomb emits invisible rays in every direction and when a ray hits a player he dies. Would that work?
Sure, but my first proposal would be technically better for a few objects. And probably easier to implement.
Such a check as you need to be written in is reasonable, but in a 3D room you would probably have so many checks so that it works properly and if you do too little checks you have difficult to debugging bugs. In a 2D room, the whole is simpler, but I don’t really see an advantage, except for a lot of objects. So usually you should keep the number of such checks as low as possible.
So I would rather make a check per (relevant) object. You just have less trouble.
Is that GDScript or C#? Because Godot has got a new update at GDScript from version 4.0 (approximately 1 year ago). Therefore, the code of ChatGPT does not work with Godot because ChatGPT is outdated.
Well, you’re doing a Ray Cast to any relevant object.
Instead of hundreds of raycasts in all directions, you’ll make exactly one raycast for every object in the vicinity, namely to the object. And then you’ll see what this Raycast is doing, whether there’s a wall in the way or not.
Here in the Godot Doku: https://docs.godotengine.org/en/stable/classes/class_physicsdirectspacestate2d.html#class-physicsdirectspacestate2d
Here ChatGPT generated example code (if you don’t have to fix yourself, only serves as an example of how this could work, ChatGPT also likes to make mistakes and thinks methods, I haven’t checked now):
Very good idea. I’ll do it in the 2D room. Yes Performance technically it could also be in the 2D range if there are very many and small rays. But I don’t understand. How should the Spie know that a player is behind an object towards the bomb if I make a check per relevant object.