Giving an object Movement. I have added a great white shark that I modelled and I would like to give it the ability of freely roaming around the world through blueprints. Can anyone help me?

Hey @FADEDTHANAHOE!

You can check out this post of mine on this exact same topic :blush:

Here’s another version of the same thing but in this one I added line trace to make it change direction when it’s about to hit an obstacle.

(This was an older screenshot of mine so I can’t edit it now. There’s one thing you might wanna change. I reset the Do Once node after it executes which is pretty pointless. It should be reset after the False node of my Branch. You won’t encounter a much of an issue if you leave it as it is, it just causes a little stutter when it’s changing the direction. But you can easily fix that the way I explained here.)

And here’s the result of it :star_struck:


As for the steps:

Right click on an empty space in your Content Browser and hit the Blueprint Class option under the Create Basic Asset section. On the menu named ā€œPick Parent Classā€ that pops up, select Pawn under the Common section. Inside our new pawn class blueprint, navigate to the Components section on the top left and hit the Add button with a green plus icon on it. Type in ā€œfloating pawn movementā€ and add the Floating Pawn Movement component. Then implement the blueprint code inside the Event Graph.

One more thing, you see inside my Line Trace by Channel node, the trace channel is set to ā€œCustomā€. That’s a custom trace channel that I named ā€œCustomā€. So you can also create a custom trace channel (optional) to determine which objects our pawn will consider as obstacles. To do that, navigate to Edit > Project Settings and type in ā€œtrace channelā€ into the search bar. You’ll see the Trace Channels section being filtered up under Engine - Collision. Hit the New Trace Channel button and name it whatever you want. But it’ll ask you what it’s default response is gonna be. If you set the default to block, you’ll need to adjust the collision responses of the objects you want to be ignored by setting them to ignore, and if you set the default to ignore, you’ll need to adjust the collision responses of the objects you want to be considered as obstacles by setting them to block.

Also in addition to already visible objects, you can place invisible walls in your level to act as borders, for example where the water ends or the borders of your map etc.


For clarity, here’s what this blueprint code does:

  • Our lil guy changes direction every 3 seconds
  • When it’s about to hit an obstacle, it changes direction at least 45 degrees on each direction
  • After it changes direction, the timer resets
  • The pawn can also be confined inside pre-determined borders

Hope this helps! :innocent: