Standing on top of part makes it go nowhere?

I’m trying to make a touch soccer ball that moves based on the angle you hit it, but if you jump on top of the ball, it doesn’t move anywhere.

I think this is because the part that touched the ball is basically on the center of the ball, so it will not move anywhere. Unfortunately, I’m not sure how to fix this.

local function applyForce(part, ball)
	local direction = (ball.Position - part.Position).Unit
	
	print(direction)
	
	local bodyVelocity = Instance.new("BodyVelocity")
	bodyVelocity.MaxForce = Vector3.one * math.huge
	bodyVelocity.Velocity = direction * 20
	bodyVelocity.Parent = ball
	
	task.delay(0.3, function()
		bodyVelocity:Destroy()
	end)
end

For anyone confused, I’m willing to provide anything, like a video or place file etc

1 Like

My goal is to make it so that even if you are the smallest bit off the center of the ball, it will still move somewhere, but this is not what happens

2 Likes

BodyVelocity is an outdated object. Use VectorForces instead.

Create a new VectorForce and check the ApplyToCenterOfMass.
Set the Force to be something big, in your case the direction. Also, if it doesn’t work, you can try setting the RelativeTo to World, or create an attachment and set the Attachment0 property to it.

local vectorForce = Instance.new("VectorForce")
vectorForce.ApplyAtCenterOfMass = true
vectorForce.RelativeTo = Enum.ActuatorRelativeTo.World
vectorForce.Force = direction * 20
vectorForce.Parent = ball

PS: Make sure the ball isn’t anchored…

2 Likes

Okay, let me try this out, thanks

Thanks, but it didn’t really fix the original issue I mentioned of it not moving when I jump on top of the ball (near the center) and touch it.

1 Like

Well probably because you are on top of it, so the ball now needs to also push up on you. You can also check the direction on the Y is positive when you jump on it. If it’s not positive then it’s going into the ground.

As for you, you can set all the character’s bodypart’s Massless property to true.

But also if you’re jumping on it there is no reason it should move horizontally, it’s trying to move up or down.

2 Likes

Yes, this has been one of the problems in the game, when a player tries to touch the ball in the air, sometimes they will hit the center of the ball with their head and it will not travel as far and it has been a big issue.

Well probably because you are on top of it, so the ball now needs to also push up on you.

In this case, the player will always (mostly) have just a tiny offset from the center of the ball, say even if it is 0.01 studs away from the x axis, I want to make it fully go in that direction anyway.

1 Like

I was just mainly wondering if there is some way I can get the full length of the direction vector somehow?

I am assuming this would require something a little bit more advanced like some angles and math functions, but I don’t know yet.

1 Like

Well if you ALWAYS want it go full power no matter how you touch it you can normalize the values.

local newDirection = Vector3.new(direction.X, 0, direction Y).Unit 

I haven’t done this before, but try this?

2 Likes

since when was GetTouchPoints a method? is this ai?