Announcement

Collapse
No announcement yet.

PostRenderFor() showing icon in hud only when in FOV of player

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    PostRenderFor() showing icon in hud only when in FOV of player

    I'm using PostRenderFor() to show an icon in the player's hud, indicating where their base is on the map.

    I've set bPostRenderIfNotVisible=true on the actor, so it will always show even when obscured behind objects. Within the PostRenderFor() function for the actor i'm calling Canvas.Project(Location) to get the screen position of the actor. The trouble I'm having is that if the player has their back to the actor it still projects the screen position as if they were standing facing it (causing almost a mirroring effect for the icon i'm rendering in the hud).

    Is there an established way to project the position on screen only if the actors location is within the players FOV?

    Here's my PostRenderFor() method from the actor i'm trying to highlight in the hud:
    Code:
    auto state Initialize
    {
    Begin:
            GetALocalPlayerController().myHUD.AddPostRenderedActor(self);
        }
    }
    
    simulated event PostRenderFor(PlayerController PC, Canvas Canvas, vector CameraPosition, vector CameraDir)
    {
        local Vector vec;
        vec = Canvas.Project(Location);
        MyPlayerController(PC).GetHudMgr().UpdateBaseBeacon(vec.X, vec.Y);
    }

    #2
    The easiest way would probably be to check whether the dot product between the player's view direction and the difference between Base.Location and CameraLocation is greater 0. Where Base is self in your PostRenderFor event above and view direction/CameraLocation something like PC.GetPlayerViewPoint(CameraLocation, ViewDirection);

    You may want to read this for more information: [UDN]DevelopmentKitGemsAddingOnScreenIndicators[/UDN].

    Comment

    Working...
    X