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.
-- 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
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])
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.
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.