Spotting Enemies Like In Battlefield 3?

How do I make a tagging system where if the player pressed a button on an enemy, there would be a tag above his head that follows him? It should also show through walls and objects. How do I do something like this? Thanks

A big question, but I think I have the necessary components for you to get started.

1. Detect the mouse/button click on the object.

This is the easiest way for mouse clicks:

If you need it to be a keyboard button, you should use raycasting:

2. Create a floating tag

This is for displaying text in 3D space for the actual tag:

If the tag is only an image then you can just create a plane and add the texture to that.

You’d have to come up with a way to rotate the tag towards the camera (easiest way is to just copy the cameras rotation). Then just position it above the target players head (parenting is a good trick here).

3. Make the tag visible through other objects.

You’ll need a new camera. Create a new layer and call it something like “Tag”. Set the culling mask of the new camera only to “Tag”. Set the layer of the actual tag to “Tag” as well. Parent the new camera to your main camera and make sure the position and rotation of the new camera are zero. Vóila.

EDIT: Couple things forgotten. The “Depth” of the new camera must be bigger than the “Depth” of the main camera. Also the “Clear Flags” of the new camera must be set to “Depth only”.