I have a game mechanic which I thought would be straight forward to implement but turns out to be the opposite.
Basically; I am trying to make a retro top down soccer game in style of Sensi Soccer. I’ve got rudimentary control, drag, and curveball systems working but I’m stuck on my semi “sticky ball” mechanic.
When the player is in possession of the ball he nudges it forward. The drag system will slow it down enough for him to catch up to it again enabling to once again nudge it forward while running. This part works fine. It’s when the player changes direction that it breaks down. I can’t get the ball to stay on the same path as the players’ direction.
Basically I need the ball to stay directly in front of the player while keeping its’ own momentum.
I want this to be physics based rather than just attaching the ball to a spring arm as I have plans to do more with this system in the future.
I’ve been told that I should do this in local space. This is how they recommended I should do it:
1. Track the relative position:
When the player is moving with the ball, calculate where the ball should be in local space—maybe something like 50 units in front and a few to the side of the player's feet, depending on how it looks best.
2. Store that offset as a vector:
Keep it in a variable so you know where the "ideal dribble spot" is.
3. Don’t fight physics—use components smartly:
Instead of constantly applying forces to keep the ball in place (which is fragile), you could have a second version of the ball as a component on the player that only activates when the player is in dribble mode. This version visually follows that relative position and moves at the player's speed (plus a bit of inertia/drag to sell the weight).
4. Use distance and conditions to switch modes:
If the ball is too far from the player, or they turn too fast, then drop out of “dribble mode.” Destroy the component and spawn the physics ball again with a force that mimics the kick.
5. From there, you’re free to tinker:
Add slowdown curves, mini-kick nudges, or predictive paths based on movement speed. The trick is to make it feel good, not to make it physically accurate.
It sounds complicated, but it’s really just three parts:
A "visual trick" ball while dribbling (as a component)
A system to decide when you're in or out of dribble mode
And a way to re-spawn the real ball when control is lost
type or paste code here
It’s the third point that I don’t understand. How can I give the ball inertia and drag while in local space?