How to code a passing script for a rugby game-blueprint

I am making a rugby game and I need a way to make the players pass the ball and hold the ball. Can anyone make the blueprint for ball passing. The ball has to go back and the player need to stay in a line. Can anyone help?

Hey there @Miker2341! So it’s not so simple you’ll be able to pull this off with one quick motion. Depending on how your game is and you intend it to work there’s many things that need to be answered in your design before you can even get to passing.

A couple important things to ask yourself:

How do the players communicate starting a pass? Are you designating a spot in front of them to throw the ball to and the other player’s AI is meant to get to that spot in time to catch it or are you stopping the player on the spot and throwing it directly?

If you’re predicting their location, you’re going to need to check the other player’s speed and heading to make sure you throw it to where they are going and can make it to.

If you are just throwing it at them in a straight line, you’ll just be able to move the ball on a spline likely an in an arc and if another player’s “Catching” hitbox touches it, interceptions happen.

Does your design work by just having the ball attached to the player when it’s in their possession? If that’s fine, just attaching the ball to the player’s hand should do the job.

I’ve dropped a couple of resources below that when combined should get you through the basics. The advanced parts are super game specific however.

Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

Attaching items to hand sockets:

Moving an object along a spline:

If you’d prefer to go the projectile instead of spline route, you’ll likely want to use the projectile path predictions so you can visualize the launched paths while you’re working on it:

Let me know if you have any questions!