Entity Always Facing Player

From CryWiki

Jump to: navigation, search


Flowgraph Walkthrough

Before the flowgraph is explained, you should note that "Octo" is only what I have called my entity, it's not a specific type of entity. However, objects that cannot be added to a flowgraph (i.e vegetation or brushes) won't work in this, so bare that in mind when creating this flowgraph.

The two EntityPos nodes are crucial in the operation of this flowgraph. The first one dynamically calculates the position of the player, and outputs it to the vector subtraction node. The second node then dynamically calculates the position of the object to be rotated (in this case, the Octo) and also outputs it to the vector subtraction node. The result of this node plus the use of the Math:DirToAngles node outputs the angle at which the object needs to be as a vector, thus allowing the Octo to be moved accordingly.

The Roll value on the DirToAngles node sets the axis on which the object will be rotated; to provide a correct rotation it should be at 180°, although this value could differ so if it doesn't work experiment with other values.

Finally, the system at the top of the flowgraph allows the object to be rotated constantly. It effectively sets up a loop that occurs every 0.01 seconds, which although technically isn't constant is fast enough so that you can't detect that its jumping every 0.01 seconds. Coupled with the speed of the rotation being set to 0 (i.e it will rotate to its destination straight away), this should mean that the object will look as if its rotating constantly.


Flowgraph Image

Preview of Entity Always Facing Player.
Preview of Entity Always Facing Player.

   

About this Sample

Name

Entity Always Facing Player

Created by

McGinge

Compatible with Multiplayer

No

Description

This flowgraph sets an entities rotation so that it is always facing the player.


Download

Click here to download this sample's Graph XML file.

You may need to right-click on the link and select "Save As" from the menu.


» Discuss this sample...

» View other Flowgraph Samples

» Return to Crysis Modding Code Samples

Personal tools