How to set the direction of a ball the as the forward vector of a character.

Ok bare with me while I try to explain what I’m trying to achieve.

I have a player and a soccer ball. I want to create a “sticky ball” situation where the ball, once under the control of the player, will move in the same direction of the player while being nudged forward a few feet but never leaves the player’s control influence.

I have it set up so when the player is facing the ball and is within a short distance of it he then has it under control. I have placed a collision box by the players’ feet that nudges the ball forwards and have set the linear damping so that it only moves a short distance.

I’m stuck on how to make the ball rotate in the same direction as the player. Also; the ball sometimes comes off at a funny angle when it hits the collision box.

Here is a little demo
https://streamable.com/bufewi

1 Like

don’t kick it, attach it to the sticky box at the feet.

On overlap, if player velocity > n , attach it.
when player velocity < n detach

1 Like

Won’t that make the ball appear glued to the end of the feet? I want to try and keep the “simulated physics” look of the ball being nudged forward.

1 Like

so you want the behavior of ball to be as it is, but should follow the character? like forward vector of character

1 Like

Yes exactly that (or were you being sarcastic? lol).

1 Like

oh no, i was just clearing out :sweat_smile:

Then, we can always cast to character, get its forward vector and set direction? maybe u can put a variable check in tick of ball actor as to when player has control, set the variable to true, and from then on in tick, set direction of ball using character’s forward vector and this u can get by casting (like u will cast to character in begin play of ball so that we will have reference) and on tick, u give the direction from character ref variable to set setting the direction of ball in tick

1 Like

I do already have a isControlled Variable on the ball as I use this to modify the linear dampening. However; there is no Set Direction node on the ball.

1 Like

i think first we have to focus on player movement as currently it rotates totally either to left or right as per blending setup … but in football games, we often seen players won’t move like this, its like a 8 way directional movement maybe?

I’m actually planning on doing 360 rotation :rofl:

I’m thinking that maybe this is something I should animate instead?

but then too, where should the ball go has to be known right?

Well yeh lol
I didn’t think it would be so difficult to make the ball go in the same direction as the characters’ forward vector while keeping the simulated physics effect. I just need the character to nudge the ball forward with each stride while retaining control.

Update:
So I’m managed to accomplish the nudging the ball forward a bit mechanic. I had to disable simulate physics and make my own movement and friction algorithm:

DEMO

But I still don’t know how to keep the ball in front of the player when he turns.
I really just thought that using the player characters’ forward vector would be enough?