Download

Back to AI after Launch Character

Hi,

I have a Pawn that uses Simple Move to, to get to my character (BeginPlay -> SimpleMoveTo). Then, I apply Launch Character to the Pawn and it moves in a direction with new speed. Now, I want to smoothly get back to AI, but nothing I tried actually worked. Without any force applied to Launch Character it is ok - Pawn moves, stops and moves again. With force it doesn’t work, just keeps floating.

What should I do, to get the AI start again controlling my Pawn?

Anybody? :slight_smile:

Launch Character overrides the current Velocity of the Actor and sets it into an IsFalling state.

If you are applying Launch Character in Tick or at a high frequency then this will cause your Character to appear to lose control of itself.

92537aebbfd56029d279c73e6f4589421f51a02f.jpeg

a3c7f2ef4e83a54cd292f31d81baf63bdc3d33bf.jpeg

This is my simple setup.

I tell the AI to always move towards to Player. In the Level Blueprint i have a simple reference to the Actor and when i Press the F Key i Launch it with a new Z Velocity to cause it to “jump”.

It loses the ability to control its velocity so long as it hasnt returned to the ground. Once it returns to the ground it will resume its SimpleMoveToActor.

In the following tutorial i explain some basic things about AI movement and Selection.

Thanks a lot I’ll watch the tutorial. I heard though that SimpleMoveTo should be called once like on BeginPlay, not in every frame (EventTick). Is there any performance difference in that?

I want to have control of when Launch Character is done and when it’s back to Simple Move to. When I have SimpleMoveTo on tick and I do the Launch in XY the comeback to AI happens to quickly.

4200aedab9b65625d82fc2aa1c717d683f8b3abf.jpeg

Like this it’s not working, the Pawn keeps floating and SimpleMoveTo has no effect. When the Enemy Force Dir is removed (I break the Launch Velocity) the pawn stops and then moves again after Simple Move to. I don’t know why, I set the Velocity to zero after Launch, so it should be exactly the same.

What is it that your trying to achieve with Launch Character?

Also it is a Character and not an Pawn class correct?

It’s like this: A bot (Pawn class, a robot - no legs, hover over the nav mesh) needs simple AI that will move him towards the player -> SimpleMoveToActor. Now, the player has a weapon that allows him to push the bot away -> apply LaunchCharacter while the Left Mouse Button is pressed.

So, the enemy is approaching, the player pushes him away, than the enemy approaches again etc. It’s like Jedi force push applied to a pawn that is controller by AI. I’m doing it only in XY.

The problem is how to get back to AI after the Launch and how to smoothly change velocity vector between Launch Velocity and constant AI speed.

You could use a radial force to force the bot back without having to disable the AI.
Just apply a force when the player fires the weapon/uses the “force”, at the location you need it to and make it only effect the bot/bots you need it too.

Hope it helps. :slight_smile:

But, documentation says that radial force is a Force, I mean, it requires physics. AI uses kinematic rigid body, so no Forces are working. Am I right?

Yes, radial force uses physics… :frowning:
I forgot about that… :frowning:

Yup :smiley:

Any other ideas?

I was thinking you could try to reverse the speed when the bot is hit by the “Thingie”(just have a variable that get’s set to -x and multiplied with the boots speed, for the duration of the knockback), make sure the boot cannot turn while it’s speed is negative or it will just back up to the character instead(i think, i don’t know if the basic AI is that smart)

Or since you have a move to the character script, you could reverse it while the bot is in the “back away” state(you could allways modify the speed so the bot moves faster away…)

Hope one of these works :slight_smile:

Or you could make a vector between the bot and the character, then disable the bots normal movement(by stetting it to 0 temporary), then move the bot allong the vector for the duration of the push…

Hmm… I don’t think i have any other suggestins right now…

Hope one works for you :slight_smile:

Haha reversing the speed sounds great, I need to try this xD thanks :smiley:

I’m still wondering though, why SimpleMoveTo doesn’t work on my bot after the Launch, even though I set the velocity back to zero after the Launch…

Talk about resureccting a dead thread…

BUT if anyone else comes looking here through google, here is the solution that I came up with:

Since “Launch Character” sets the AI’s movement to ‘Is Falling’ it will no longer use its basic Move To behavior until it is no longer falling.

So, after launching your AI back, set a short delay node, and then use ‘Set Movement Mode’ to walking (or whatever mode you use - mine is flying in the example). The AI will then go back to moving to where it is told. Hooray!

All of these solutions didn’t work for me.
I found a good alternative, however (by looking at the engine source code).

Just set at DefaultEngine.ini


[/Script/Engine.NavMovementComponent]
bUseAccelerationForPaths=True