I have this customizable Area of Effect indicator using a single material as a decal, attached to an actor. What I’m struggling with is finding a way to detect whether or not the player is standing inside an AoE.
Referring to the image, I can produce “complex” shapes (rainbows/cones/donuts/etc). I absolutely do not want to create object meshes for each possible shape. I don’t need to tell you just how many 3d models that would be based on the sliders in the image.
Originally I’ve tried using sphere/capsule colliders for the circles, but introducing a “cone” has made this infinitely more complex for me. I also tried using the Procedural Mesh component, but wasn’t quite sure of my ability to use it.
Again, I really want to stay away from creating 3d meshes for each possible AoE I can make. Other than that, I am looking for any help I can possibly get.
donut is checking whether the target is in min | max range
What I’m struggling with is finding a way to detect whether or not the player is standing inside an AoE.
If you do not want to create uniquely shaped colliders, you’ll need to math it out. Sphere overlap nearby targets and then iterate to check whether they meet other criteria like the min range (donut hole) or dot product (cone).
Create a scene component.
Rotate the scene component locally by whatever the rotation axis needs to start at (say -60 degrees)
Add and child a box collider to the scene component, with a width of 1-unit and a length of the radius of your AoE
Then, rotate the scene component locally by whatever you need adding any ‘beginOverlap’ actors to an array
After rotation finishes apply you effect to the array of actors
OP said "Originally I’ve tried using sphere/capsule colliders for the circles, but introducing a “cone” has made this infinitely more complex for me. "
I offered a solution for the semi-circular ones in their post, and it can be adapted for use with the other shapes. For example, you can do the cone by using two box colliders, and get the base set of relevant actors with one, and remove those from outside it by a certain radius by having a second longer collider rotate at a wider angle.
The 'rainbow shape can be created with a box or sphere collider, offset from the scene component, and then rotate the scene component around the x
I mean, I’m just offering one solution, which can be used for OP’s purposes. It might not be the ‘best’ way, but it was the first solution that came to mind, and I figured a ‘not perfect’ answer which at least does what they’re asking for is better than no answer.
I’ve never used physical material masks but I believe you could make a physical material mask with two physical materials, one would be for the hit area and the other for the no-hit area, and then you could do a line trace from the character to get the physical material and the distance and see if character is within hit range.
(I’m a newbie and have no idea if that would work)
Ha, alright. Honestly, reading up on dot I think it’s likely the more efficient method, from a technical standpoint. I mainly went for the collider option since OP said they had tried, and I was able to visualize it mentally. I’m more of a visual person these days, so I suppose that’s where I was coming from. I mainly was looking at it like using two colliders to create essentially how the Spot Light has “Inner Cone” and “Outer Cone” but as a way of shaving off the actors outside the inner one.
I’ve been playing around with this method and I’ve noticed a small issue. If the player is standing too close to the center, the DOT product registers as being less than the angle of the cone, even though it’s well within the range.