Curving Ball using Mover Constraints

Trying to curve the balls trajectory


        local ocCurveVector = (character.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0 ,math.pi / 2, 0) * CFrame.fromEulerAnglesXYZ(math.rad(0), 0, 0)).LookVector
        
        forceApplier:ApplyLinearVelocity(direction*Vector3.new(1,0,1),speed,maxForce,yForce,timeApplied,targetBall)
        forceApplier:ApplyAngularVelocity(Vector3.new(0,50,0),500,0.3,targetBall)
        forceApplier:ApplyForce(ocCurveVector*800,0.5,targetBall,true)

My code

My issue with it is that the curve applies far too late and irregularly
I want it to be smooth
and applied almost instantly

3 Likes

Right away it sounds like a net code/ownership swapping issue, but on the off-chance that it’s not:

  • We don’t know what the “forceApplier” module is to be able to help with/logic through those functions
  • Your description of the problem isn’t technical/specific enough to be confidently assisted with
  • math.rad(0) is equal to 0
1 Like

It’s definitely not an ownership issue, in the video the ownership of the ball is with the client.

We don’t know what the “forceApplier” module is to be able to help with/logic through those functions

I thought the functions names were self explanatory, but I’ll send the code if it helps.

Your description of the problem isn’t technical/specific enough to be confidently assisted with

I don’t know how else to describe it. I’m trying to make the ball curve inside (ie. to the left in this case).
ApplyLinearVelocity applies a forward and up motion, AngularVelocity is for the spin, and the ApplyForce is for the curve.

1 Like
function module:ApplyLinearVelocity(velocity,speed,maxForce,yForce,timeApplied,targetBall,curveVector)
	local linearVelocity = Instance.new("LinearVelocity")
	linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.World
	linearVelocity.MaxForce = maxForce
	linearVelocity.VectorVelocity = (velocity * speed) + Vector3.new(0,yForce,0)
	linearVelocity.Attachment0 = targetBall.VelocityAttachment
	linearVelocity.Parent = targetBall

	Debris:AddItem(linearVelocity,timeApplied)
end

function module:ApplyAngularVelocity(angVelocity,maxTorque,timeApplied,targetBall)
	local angularVelocity = Instance.new("AngularVelocity")
	angularVelocity.Parent = targetBall
	angularVelocity.Attachment0 = targetBall.VelocityAttachment
	angularVelocity.AngularVelocity = angVelocity
	angularVelocity.MaxTorque = maxTorque

	Debris:AddItem(angularVelocity,timeApplied)
end

function module:ApplyForce(vectorForce,timeApplied,targetBall,curve)
	local vForce = Instance.new("VectorForce")
	vForce.Attachment0 = targetBall.VelocityAttachment
	vForce.RelativeTo = Enum.ActuatorRelativeTo.World
	vForce.Parent = targetBall

	Debris:AddItem(vForce,timeApplied)
end
1 Like

The VectorForce is being applied relative to the world which I believe would mean it’d be inconsistent based on what angle you kick the ball at, perhaps . . . ?

Working with Roblox’s physics is unfortunately always going to be slightly variable in its results, so the unreliability is also something to take into account

1 Like

The issue isn’t with the direction of the curve, the issue is with how late the curve applies

1 Like

Bump

1 Like

This is separate, but can i buy/recruit you for animations

1 Like

I can tell you how to do the curves, since ive done it on my own football game

1 Like

Can we see the code before you apply the force? Also the delay may be because you are creating instances, but I’m not sure.

1 Like

I checked and it seems the delay happens because of the LinearVelocity. No other force can be applied for some reason until the LinearVelocity leaves… very weird

I’m not the animator, but I can give you the contact of the person who made them

1 Like

Did you use a physics based system? and did that system use BodyMovers or Mover Constraints?
I’ve done it before with BodyMovers however it behaves differently when ported to Mover Constraints

1 Like

This is kinda jank but you can try using task.spawn

So like:

task.spawn(function()
--apply force
end)
task.spawn(function()
--apply force
end)
task.spawn(function()
--apply force
end)
1 Like

I don’t really get the idea behind this.

What I want is for the force to applied simultaneously with LinearVelocity, wondering if theres a way to do that, that’s all.

1 Like

task.spawn() basically runs whatever code within there “seperately” than what comes after. So if you do task.spawn(function()
task.wait(1)
print(“There”)
end)
print(“Hello”)

It will print hello, then wait one second and print there.

1 Like

I’m aware what task.spawn does, but I don’t see how it’ll be useful in this scenario

Oh shoot that is my bad. I thought you meant the code was not adding the force instances simultaneously. What if you used Assembly linear velocity instead of the Linear Velocity Instance? Try it out and lmk if it works or not.

1 Like