Ball Striking Physics

I want to create a semi realistic ball striking system similar to the one in FIFA and this, Shooting - Clipped with Medal.tv. Currently the ball doesn’t seem to rise at all and doesn’t really lose any sort of speed or power. This is a demo of what I have currently: Shooting - Clipped with Medal.tv
I’ve tried adding an antigrav to the ball so I can see the intended trajectory and this makes the ball go directly to the target of the mouse, so now I’m stuck trying to get the ball to actually traverse towards the mouse location with any form of actual power.
Current


Ideal

code:

-- anti grav so that the ball doesnt stop
		local antiGravity = Instance.new("BodyForce")
		antiGravity.Name = "antiGrav"
		antiGravity.Force = Vector3.new(0, workspace.Gravity * ball:GetMass(), 0)
		antiGravity.Parent = ball
		
		--hits ball off
		ball.CollisionGroup = "midShot"
		ball.CanTouch = true
		ball.Velocity = CFrame.new(plr.Character.HumanoidRootPart.Position, mouseHit).LookVector * power
		ball.CanCollide = true
		--pwr = power
		shooting = true
		print(power)

have you looked into AddImpulse ?

What’s the difference between an impulse and a normal bodyforce?

You should avoid using BodyForce whenever possible since it is deprecated.

The main difference is how both work. BodyForce is more like moving an object to a position while AddImpulse (or whatever the function is named on roblox, i only know its name on UE) is much more “unstable” (which I assume is what you want for a futbol game [it still gets to its destination and it seems less robotic, more authentic])

Oh, alright thanks for the explanation. I’ll try it and see how it goes.

Impulses are definitely what I needed after testing, but I’m struggling to get it to go exactly where the player mouse is? When I aim in the corners of the goal the ball just travels flat.

Flat how? Is it stuck on the ground or just spinning towards the goal?

Try making using the AddImpulse like J9White says, you should have a default power, a power percert (how fill the bar is from 0 to 1) and a vector unit direction, that could be for example: character.HumanoidRootPart.CFrame.LookVector. Take that vector3 and do something like ball:AddImpulse(dir * power * powerPercent)

If you want the ball to go up a bit, i sugest to rotate the direction up a bit:
(character.HumanoidRootPart.CFrame * CFrame.Angles(math.rad(30),0,0)).LookVector

I’m missing alot of the accuracy and consistency now that I’m applying impulses. 1st video is with impulses, 2nd is with a velocity and antigrav applied. I want it to be able to consistently at least move to the mouse location especially without as much force and speed required.

External Media External Media

with anti grav

		local antiGravity = Instance.new("BodyForce")
		antiGravity.Name = "antiGrav"
		antiGravity.Force = Vector3.new(0, workspace.Gravity * ball:GetMass(), 0)
		antiGravity.Parent = ball
		
		--hits ball off
		
		
		local direction = Direction(ball:GetPivot().Position, mouseHit) * 400
		ball.CollisionGroup = "midShot"
		ball.CanTouch = true
		--ball:ApplyImpulse(direction)
		--ball:ApplyImpulse(direction)
		ball.Velocity = CFrame.new(plr.Character.HumanoidRootPart.Position, mouseHit).LookVector * 100

with impulse

		ball.CollisionGroup = "midShot"
		ball.CanTouch = true
		ball:ApplyImpulse(direction)

seems like too much power. Try what Luca1006 said

Doing this gets closer to what I’m wanting but it’s still widely inconsistent. Is there any way for me to make it more “predictable” since this game is going to be competitive. I don’t want for example a bad impulse screwing over a shot on goal and frustrating people.

What do you mean with inconsistent?, if you want the ball to go to the mouse position, i will recomend seeing this video of Shupi: Projectile Physics - Roblox Scripting Tutorial - YouTube (17:46)

You could addapt the code from the video to kick the ball to the mouse