What is the suggested way to create a selection outline like one you have in RTS games?
The immediate solution i can think of is attaching a plane to object with transparent texture.
But I’ve seen some that “stick to terrain”, instead of being occluded by it. It is more advanced than that for sure.
I’d suggest looking at projection textures. You can tell a light to project a texture down onto your scene. That way the the texture will look like it’s mapped onto your terrain wherever your character is. So to achieve what you’d want, you’d have a light that projects a texture of a “selection circle.” Then you could move that light on top of whichever character was selected.
I then create 4 boxes, give them different colors, and give them random positions on the ground. Note that there’s a tricky bit in here where I raycast to figure out the height of the ground, to place each box on “top” of the ground.
I create a spotlight and give it the green circle texture as a projection texture, then whenever you pick a mesh that is NOT the ground (so one of the boxes), the light will shift to project over that box.
Note that the texture I’m using is a green circle with black around it. The black masks out the light projection. So the light will only project the green circle.
I know that’s a lot to digest, but hopefully it’s helpful in answering you question.
Again, I’ll do a video on this in the coming weeks!