Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
moving_entity.jpg

Learn how to add moving Gameplay Entities

(a boat,

onto the level.

These steps can be applied to a ship, a plane

,

or a flying whale

, windmill) onto the level

.

In this guide we will add start small by adding a boat to the level with a mesh and dynamic colliders. Later we will also set an animation and set its curve.


Setup

First enable the debug filter AnimatedProperties so you can actually see them in the Editor (HOW-TO: Change display settings).

847d785c-6817-4aaf-acd6-658c4790ae1f.png

Create Entity Template

Then create a new Entity Template. Change its class to GameplayEntity - this class and its children have access to PropertyAnimation, which we will be using for our movement.

Info

You can backtrack to this HOW-TO: Create a new NPC guide to learn more about entities.

1079a0d1-275a-4fba-a9e1-36de1d65fbfc.png

Add mesh

Add a mesh into the entity. Find the boat_row_wooden_old.w2mesh file in the Asset Browser.

Select the file and drag it from the Asset Browser into the entity template’s graph. Choose Rigid Mesh Kinematic in the Create Mesh Component popup.

6ab5e1ca-d0ba-4895-8761-7b31702086f9.png

Add dynamic collider

Add a dynamic collider component (CDynmicColliderComponenet0) on the Entity’s graph and make sure the useInWaterDisplacement property is set to true (the component will displace water).

2024-06-10_08-28.png

On the graph, connect the Mesh and the Dynamic Collider by attaching them to each other via Link using CHardAttachment.

This will make sure the collider follows the mesh.

a030ba6d-cc8c-4696-9a18-dacddf3a25de.png


Add entity to level

Time to place the Entity on the level (in the Editor’s viewport).

Go to the Entity’s properties. You can add a new PropertyAnimation with the CPropertyAnimationSet class.

You need to choose which components the PropertyAnimation will affect. Click on the 🔍 icon in the CGameplayEntity > SPropertyAnimation. A pop-up with a list of properties should appear. Select the Base Objects > transform [EngineTransform].

It’s also possible to move specific components, but we want the whole boat to move.

6fe22716-ec6f-495f-ae50-3cecc9dd68a1.png

PropertyAnimation

Name the animation move. Tick the “playOnStartup” so we see it immediately.

Otherwise that animation would have to be called from scripts or specifically pointed out in the quest graph.

4d129125-125e-4573-8e93-bee62dbf5fdf.png

Curve

Now, click on the curve field and on the right side the wiggly, snake-ish curve icon.

2024-06-10_08-44.png

You should now see a debug view of the curve on the level - similar to the one on the screenshot below.

If it’s not visible, make sure you enabled the debug filters for Animated Properties (first step of this guide).

b87c87cb-5e5d-49bf-9fd8-bdce56837284.png

You can change the totalTime of the whole movement under SMultiCurve.

Let’s change it to 30s.

b74ab676-d60c-4373-84b6-0643b86e7875.png

And now we can move the curves points around on the level.

You can right click on a control point to Add a new point before/after the current one. You can also Enable looping, which will connect the start and end points.

2024-06-10_08-46.png

Test curve

You can also check how the movement would look in the game via Visualization > Enable Curve Run.

In the Editor you will not see the Entity itself but just a red cube splashing around in water.

c78bb02e-81ba-4714-8861-6d33d03e3521.pngf4d001bb-bf29-48ef-85c4-4e131e587709.png

Create a loop

Now add a couple more points and Enable looping.

Info

Some useful shortcuts: Y key can be used to snap the point to the mouse position, just like with actors. Coma and Dot keys (, and .) can be used to cycle through the points when one is selected.

02d1d767-ab60-4d7d-98c5-d58e1142dd49.png

You will notice in game that the boat is not actually turning.

To fix this we need to Enable automatic rotation from direction recalculation. Right click on a point and choose this option:

6947a0d4-c4a0-4f03-b992-3f1f42d4997d (1).png

Done!

Now the boat should rotate properly!

99f5686e-a07f-4dee-991d-38fdf8154f17.png

Up for a challenge?

For a more complex entity example, you can try setting up movement for this boat paddler available in:

  • prologue_village level - living_world\scenes\entities\boat_man_prologue_02.w2ent

Good luck!

7b31b932-a52a-4172-978c-385467535c92.png

Table of contents

Table of Contents
maxLevelclass
maxLevel6
minLevel26
include
outlinefalse
indent
styledecimal
excludeLearn how to add moving Gameplay Entities (a boat, ship, plane, flying whale, windmill) onto the level.
styledecimal
typelist
printabletrue
class