#help with trajectory prediction with 2 force simultate

1 messages · Page 1 of 1 (latest)

proven seal
#

Hi Everyone,
so basically, I have a script on Roblox that simulates the trajectory of a ball and its point of impact. The idea is simple: I generate a ball with an initial speed, I draw its trajectory by placing lots of small green dots in space (like a prediction mode), and when the ball is supposed to hit something, I spawn a big red dot to show the impact. All of this is done using raycasts and frame-by-frame position calculations.

The thing is, I want to make a soccer game, and in this game, I’d like the balls to have effects, kind of like in Inazuma Eleven or FIFA. You know, like a curved shot or a deviation due to some special force. The problem is, even though I already have a VectorForce applied to the ball in actual gameplay, it's not taken into account in the trajectory prediction. So visually, the ball goes straight, but in reality, it curves because of that force. It's not consistent.

I've tried a bunch of stuff before coming here. I tweaked the forces, I tried integrating them in different ways, I attempted to simulate them inside the prediction loop, but it never works the way I want. And honestly, I’m out of ideas—this is really my last card to play. I think I need to apply that force at each step of the calculation in the CalculateImpactPoint function, but I don't really see how to integrate it cleanly without breaking everything.

So what I want now is a predicted trajectory that takes this additional force into account, as if it were applied the whole time—not just when the ball is first created. That way, what we see in the prediction actually matches what really happens in the gameplay.

**HERE IS THE SCRIPT BELOW : **
https://pastebin.com/CUFkXUBe
Thank you in advance for your reply

long bloomBOT
#

studio** You are now Level 3! **studio

jagged coral
proven seal
jagged coral
proven seal
proven seal
# jagged coral Do you know how gravity is implemented?

I had this formula:
currentVelocity = currentVelocity + Vector3.new(0, -gravity * timeStep, 0)
Then I added this:

  • (Force/Mass) * timeStep
    So now it's:
    currentVelocity = currentVelocity + Vector3.new(0, -gravity * timeStep, 0) + (Force/Mass) * timeStep
    And it seems to be working correctly
quartz wind
proven seal
#

i see that

#

thx

#

x)