I am currently making a soccer game and I am trying to make moves that players can do with the soccer ball, however I’m confused on how it will work. If I should animate the soccer ball with it or other solutions. This is somewhat similar to basketball dribbling since I don’t know how it works, so if someone could explain it to me that would be great.
Depends on how you want the game, in basketball it’s easier just to do an animation, since it’s just a continuous loop of going up and down.
Soccer is different though, to dribble a soccer ball you’d have to walk up to the ball and kick it and then repeat this but with every stop. Though, that doesn’t mean you can do an animation of the ball going back and forth from your feet it’s just wouldn’t look good.
So another way you can have dribbling, is detect if the player runs into the ball, and if they do make the cframe of the ball go in the direction their looking, this will look okay, but will also have an issue of it not looking smooth.
Another option, is to have a tween or a normal velocity on the ball be placed on it. It’d be the same way with the cframe, the velocity or tween will play or emit when they player is in front of the ball and moving. Causing the ball to go forward a little in the direction the player is looking. Warning - if you use a tween changing the direction of the ball will be difficult because you’d have to stop that tween for the first player and start a new one for the second player.
To get the direction of the player and emit
local Char = -- The character
local Ball = -- The ball
-- How you'd do the tween
local Tween = game:GetService("TweenService"):Create(Ball, tweeninfo.new(0.5), {Position = Ball.Position + Char.HumanoidRootPart.CFrame.LookVector * 5})
-- How'd you do the velocity
local VelocityOfBall = Ball.Velocity
VelocityOfBall = Ball.Position + Char.HumanoidRootPart.CFrame.LookVector * 5
-- How'd you do the CFrame
local CFrameForBall = Ball.Position + Char.HumanoidRootPart.CFrame.LookVector * 5
Ball.CFrame = CFrameForBall
These are just examples, actually implementing the methods I suggested you’d have to take that upon yourself.
Ok Thankyou very much I will try this and get back to you as soon as I can
I want the soccer dribbling to be like FIFA soccer dribbling(realistic dribbling) Could you explain more on the tweening sides because its more likely i would use Tweening since i would also implement Bezier Curves into Shots and passes