How to make a simple patrolling Super Mario Enemy AI?

Hi guys!

I am struggling a bit with something that should be pretty simple to set up. I need a couple of patrolling Super Mario AI bots in my 2.5d game and I currently got this setup:

  • The bot is based on the character class
  • I use two editable target point object variables, so that I can manually setup movement targets for each bots in the scene.
  • And this is how the main portions of the graph looks:

The problem though, is that the signal runs through the graph immediately, which makes my bot return to the start point before it even reaches the first target point. I would it to reach the first target before it can return to the start target. Is there an easy way to tweak this setup, so that my bot has to reach each target before it can continue to next?

Cheers!

I would add a boolean variable in the blueprint called ‘ActiveTarget’ whch will be an Actor type.
Initially this variable will be pointing to TargetA. Then I will add a beignoverlap and check if I have overlapped with TargetA or TargetB. IF I have overlapped with TargetA, I will set ActiveTarget to 'TargetB. Conversely, if I overlap with TargetB, I will set ActiveTarget to TargetA .

Within the event graph you have shown, I modify it and always set the Destination to ActiveTarget->GetActorLocation.

This way he will ago back and forth between the two points.

However you could make it more general, by removing the TargetA and TargetB actors. Instead simply add a Hit event and switch the value of a variable (lets say ‘VelocityMultiplier’) between -1 and 1.
Within the Tick event, I will simply multiply the characters velocity with this multiplier. SO he will reverse his walking direction everytime he hit something. I think this is how Mario enemies work.

The problem in your setup, I think is because you are calling ‘Move to Target B’, and then after a small delay you are calling ‘Move to Target A’. I think Move To function is an asynchronous function, meanign it will return immediately and the task of moving to the destination happens in background. So effectively, you ask your character to move to Target B and within 1 second you ask him to come back to TargetA

That’s right, MoveToLocation is not a latent function and what it actually does is it requests a move and then instantly finishes. I’ll have that function renamed to RequestMoveToLocation to make it more clear.

For a simple AI move scripting I’d suggest using AI Move To BP node, but it’s broken in 4.2 :confused: But we just fixed it! (literally 10 minutes ago :D). I’ll make sure it’s included in the hot fixes.

does the broken 4.2 AI Move To automatically fix or do we need to upgrade to 4.3?