Announcement

Collapse
No announcement yet.

Set Float based on GetDisanceTo

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

    Set Float based on GetDisanceTo

    Hi guys,

    I'm trying to change a player's variable based on their proximity to a world actor/s.

    Actor BP: 'EnergySource'
    PlayerState variable: 'SourceDistance' (Float)

    Below is the logic I have setup in my PlayerController class but when I launch the game, the 'Print Text' fires correctly but the variable doesn't change, it simply prints the same value over and over again. It seems to be an incorrect reference to the player perhaps? I wasn't sure how to reference a specific world actor so I did it by Array of actors, but I'm not sure if that's a good way of doing it?

    Click image for larger version

Name:	vnZ8h3L.png
Views:	1
Size:	123.9 KB
ID:	1170363

    Any direction would be much appreciated

    Thanks - Chap

    #2
    You shouldnt use GetAllActorsOfClass in the Tick Event, its pretty performance heavy and doing it every frame can be troublesome.

    So instead of using the PlayerState as your Target input in the GetDistanceTo node, you will want to use the PlayerCharacter instead. Your PlayerCharacter is the visual representation within the GameWorld, PlayerState itself exists as a data only class and shouldn't be used for any type of location acquisition as you have attempted there.
    Im an Moderator on UnrealSlackers Discord! Which is a Community driven group of likeminded people here to discuss UE4! Join UnrealSlackers on Discord!

    Comment


      #3
      Ah yes! of course! I completely over looked that. Thanks very much mate!

      Out of interest, how would you suggest I execute the event as apposed to an event tick?

      Thanks again!

      Comment

      Working...
      X