I am making a local multiplayer soccer game in which all players are in first person. I need to make it so the players will be able to add an impulse to the ball on button click when they are near it, sort of like a kick. There will be no animation, so I don’t have to worry about that, but I need to make the ball fly in the direction that the players are facing when they “kick” it. Thanks.
You will want to use a setup similar to this one
This is all done in the player’s blueprint. Each player will need to get a reference to the ball’s mesh. Kick strength is a float variable within the player blueprint.
An explanation of what’s happening:
- Get the forward vector of the current player, it will only be 1 long.
- Multiply the forward vector by the kick strength, now we have a strong force in the vectors direction
- Apply that force the the Ball mesh 1 time.
Sometimes (depending on the mesh or other variables) the kick strength will have to be really high, so if it doesn’t move try making it bigger.