New tutorial on how to create a following pet
Tutorial for Unreal Engine 5
AI serie
Step 1 : Create a BlendSpace
1.1 In this example we use a normal Blend Space, not a 1D Blend Space to be able to add the direction axis later on if needed
1.2 The speed value here is 600,
*the idle anim will be played when your character has a velocity of 0
*the walk anim will be played when your character has a velocity of 300
*the run anim will be played when your character has a velocity of 600
Now you can code on your character BP a logic to change these values (for instance if the pet is far away from you, it will have a speed of 600, otherwise a speed of 300)
1.3 Remember to hold CTRL to see the result directly on the blendspace
Step 2 : Create a Character Blueprint for your AI
2.1 Change the mesh with the one from your pet
2.2 Relocate to fit the capsule and the directionnal arrow
Step 3 : Create an Animation Blueprint
3.1 First the EventGraph to get the character speed and store it into a float variable
3.2 Then the AnimGraph to place the BlendSpace and connect the speed variable with the one from the blend space
Step 4 : Add a pawn sensing component and make a simple code
4.1 Very basic but really important componant to any AI, easy to play with some values if needed
4.2 Right click on the component to see the available events, here we need the "on see pawn event"
4.3 The "AI move to" node is very easy to use and very efficient. Here you can notice I only used the "On success" pin but you can also use the "On fail" to add more logic.
4.4 I used a simple delay node after the success but you can add much more intersting things here
Step 5 : Place a nav mesh Volume on your map
5.1 No nav mesh = no AI movement on your map
5.2 Press P to see if the volume fits your map correctly (green areas)
#epicgames #unrealengine #tutorial #gamedevelopment