Linear Velocity on Line causes the ball to act weirdly

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to create a ball that isn’t laggy on the server and even less laggy on the client side and my best solution, linear velocity on line, has some strange quirks

  2. What is the issue? Include screenshots / videos if possible!
    The ball is flinging really far while touching the wall

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

  • Assembly Linear Velocity (it worked but it doesn’t work sometimes for no reason)
  • Every other type of velocity with cloning the ball to match the ball on the server (I created a velocity thing and deleted it a couple milliseconds later so there might be a better way to make that)
  • Detected when the ball touches a wall then stops the velocity (i did it pretty sloppily so this might be a solution)

I appreciate

  • Different methods that you think will actually work
  • A fix to my current issue

You could use the vector 2 of the linear velocity of the ball and find the normal of the wall. Then you could use the dot product formula to get the angle between the normal and the Vector2. Then you could cast another vector 2 from the normal of the wall where the ball hit with identical velocity (or less) to simulate a bounce off of the wall.

If you want the ball to just stop when it hits the wall though, I would recommend revisiting your implementation of that.

Hopefully this helps!

P.S. The dot product formula is a⋅b = |a|*|b| cos θ where a and b are vectors and θ is the angle between them.

1 Like

I might’ve worded my post wrong, but what I’m looking for is a way to stop the glitch from happening.

Appreciate the comment though

1 Like

You could maybe apply an small impulse with BasePart:ApplyImpulse() when a player ‘kicks’ the ball, this would make sure that the ball would slow down eventually and not cause much lag, unlike forces which move the part indefinitely until they are set to (0,0,0). Assuming the ball is a BasePart ofc

The ball is a root part + a mesh part, so it wouldn’t work. I tried it and it didn’t seem to do anything.

I thought imposing a velocity on it in a natural way instead of letting the engine do its thing might have helped. I haven’t worked with assembly linear velocity before but I read about it and thought you could just set it to whatever you wanted.

Sorry for the miscommunication tho hopefully you find what you are looking for!

Assembly linear velocity did work, but it sometimes just didn’t kick the ball.

oh ok thats interesting, like the kick just didnt interact with the ball? was it a logic or engine issue? did you run print statements through it? because really I think the jenkyness could potentially be solved here instead of a brand new solution. maybe?

The hitbox detected the ball and I assume that the engine couldn’t keep up

I just raycasted using the linedirection of the linear velocity like every frame or something and then I halved the linevelocity to simulate the ball slowing down

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.