Hi all. Im trying to figure out how to implement AOE attacks that orginate from a player that conform to the map. For example, if theres an obsticle next to the player, the AOE wouldnt just pass through the obsticle. I've attempted to attach an example of what I'm hoping for, however I'm not sure if its even possible. The sprites for the asset are going to be hand drawn so they technically have a fixed shape, and would need to adapt. As a refernce concept for where this might apply, think of a flamethrower cone style attack. Some other work arounds I was thinking could just be remove the concept of having "walls" and instead all obsticles are holes, so its fine if attacks go over them, or just tough it out and loose the little bit of realism and let attacks just clip through the the otherside of walls and such. Any help would be amazing! I am aware that my post mightnt perfectly illustrate my issue or what I hope to achieve, so please ask for clarification if needed on anything.
#AOE Attacks in 2D game without particle system
7 messages · Page 1 of 1 (latest)
Another approach I've been thinking about is ontop of the general sprite, have the collider be calculated by a number of segmented raycasts, if the raycast finds a wall before where the cone would end, then it would create a sprite mask that is perpendicular to the contact surface and extends back to where the sprite would stretch too, and then places a "contact" sprite on the collision point (making it look like its hitting something instead of just being cut off. I worry this may end up looking messy, and that the edges would look strange.
Similarly, could also look at having the following instead:
You can make it in two steps.
- Make trigger collider on you AOE area cone without walls. Check is there any enemy in it every frame.
- For every found enemy, shoot raycast from enemy to the source of attack. It there will be a line of fire without walls, it should take damage.
If you want the strictly first picture, you should shoot raycast not to source, but in the direction, left for this pic. And getting the correct length can be a problem too. It will take some vector projection magic.
It can cause some problems with big monsters. If you want them to burn when their center is covered, but their side is not, you can make ~4 raycasts from different points on the enemy, preset at the border. People usually make similar things for stealth detection systems.
And VFX can be a problem. If you don't want to use phys particles, your vfx will pass through walls, and I don't see how to fix it. It can confuse player, because visual attack will reach the enemy, but not damage. But even big companies sometimes leave it without a solution.
Thanks for the help, that's the rough idea I'd come up with, I'm thinking about using the raycast to mask out individual flame sprites so it can not pass through things better
I didn't even think about the behaviour with large enemies though, thankyou
Im thinking maybe to handle this I instead use the ray casts to identify "hittable" enemies, and then have a big cone trigger collider that only damages enemies that are marked by the raycast