Add Impulse - What dont I understand (Be Gentle)

HI
Ive just come back from a long break on UE and im trying to use the Add Impulse function to move a ball in a certain direction.
I can add the impulse and make it move but it will always follow the X axis which is not the correct line I want the ball to take.
How do I fix this so the ball will go in a direction I decide?

Thanks in Advance

Solved guys
although im shocked its as simple as using the - icon??

1 Like

@swhite68

Hello! :smiley:
The ball was only moving on the x-axis, because in the transform you had entered a fixed value only on x.

So, if you wanted to move it, on multiple axes at the same time and on variable values, you need additional logic. Also I don’t think doing a get actor every time you press b is the best thing. Create a variable and set it as the ref of the ball you want to manipulate.
It should be lighter to run.

Hi
I agrre, the idea is this functionality will be called alongside an animation that the AI character kicks a ball to the player, so i was just using the button to test :slightly_smiling_face:
Im really struggling with how i can get the ball to go towards the the Player Character position (the player character position will be moving)

I thought if I get the player location and then plug that into the vector it may work but nope :frowning:

Any thoughts??

1 Like

Ok so a little progression :slight_smile:
I have adapted the code and can now get the ball to go to my player wherever they are on the pitch but …
why is there always a but…

it is only using a certain strength to kick the ball, not allowing me to dictate the strength of the impulse.

How can I update this so that I can specify the strength of the kick?

Thanks in advance

1 Like

Morning! @swhite68

The first thing I thought, is to try to add in the ball’s bp, a spline (utility) to use as a path for the animated ball itself;

Example :

and find a way in run time to modify the last point of the curve so that it reaches the player’s position, when the AI ​​wants to kick it. So surely the animation can be smoother and more realistic, because a curve can easily travel multiple axes at the same time.

@swhite68
But on the sphere did you activate “simulate physics”? Did you try to multiply the vector you pin in “impulse”? If not, try and use a large number, otherwise you could have the ball immobile. However if the ref you created did not work, do the get only once in begin play , doing “isvalid” on the bp/component

1 Like

Alternatively, Normalise your subtraction vector and then multiply it by a float; but why bother - Get Unit Direction is cleaner.


You do not need to use the At Location variant of the Add Impulse node here. That’d be needed for additional simulation characteristic where the location of the kick on the ball’s surface matters.

Another tip: immediately stop scripting in the Level Blueprint and move you script where it belongs:

  • input goes into the player controller / pawns
  • ball behaviour goes in the ball actor

Or you will need to rewrite the whole thing very soon…

1 Like

Thank you all so much for your feedback.
I have moved the code into the correct place (as requested) :slight_smile:
I tried to use the Get Unit Direction function but it kept sending the ball the incorrect way so I managed to use some of the example as mentioned an now have it working :slight_smile:
So this is the code for any future people that I got working"

Once again thanks for taking the time to help, it is appreciated

1 Like