Pages

quarta-feira, 22 de março de 2017

BP Compendium 3: Get Actor Forward Vector

Get Actor Forward Vector


Function that returns a normalized vector (length = 1) that represents the direction an actor is pointing to.

Output

  • Return Value: The vector indicating the direction of the actor.

Example Usage: 

This image shows how the player moves in the "First Person Template". The "InputAxis MoveForward" event uses the "Get Actor Forward Vector" to move the player forward or backward based on the value of "Axis Value". The "InputAxis MoveRight" event uses the "Get Actor Right Vector" to move right or left. For example, using the standard WASD keys for movement, the W key activates the "MoveForward" event using Axis Value = 1 and the S key uses the "MoveForward" with Axis Value = -1 to reverse the direction. The "InputAxis MoveRight" event is triggered by the D key (Axis Value = 1) and the A key (Axis Value = -1).

Click to enlarge

"Get Actor Forward Vector" is also widely used to perform "Line Traces" in order to check if a shot has hit a target. Another type of "Line Trace" that is being used below is to check if it has an object nearby (2 meters) and in front of the player to interact. 

Click to enlarge

If the "LineTraceForObjects" function find an object, it is returned in a "Hit Result" structure. A reference to the found object can be obtained in the "Hit Actor" variable of the "Hit Result" structure.