Roblox Physics Question (Animations)

When I use an animation to move the puck forward, the puck doesn’t move.
However, when I use my WASD keys and hit the puck (refer to gif) the puck moves.

https://gyazo.com/e4a7a33a3a7dde4eecaef0f574036506
The 1st attempt is the animation, 2nd is me turning into it.

How can I get around this so that the animation does move the puck?

Does the player have network ownership of the puck? Also you could attempt to add artificial velocity when the stick interacts with the puck, where the velocity is in the direction of the player.

Hey Epic,
Just added the network ownership (same result). How would I move the puck in correlation with the direction the stick is moving so that it looks authentic?

I’m 20 minutes late! Sorry!

Yeah I don’t think you will need to do that since I assume you’re giving the nearest player network ownership the physics handler will do it for you probably.

Also if you still want to do that you can use the LookVector of the player and multiply it by some scalar (force value).

local velocity = humanoidRootPart.CFrame.LookVector * force

No problem :smiley:

I tried doing this but the puck still seems to not want to move.


Puck.Touched:Connect(function(Hit)
	local check = Hit.Parent:FindFirstChild("Humanoid")
	if check then
		local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	    if Puck:GetNetworkOwner() ~= Hit.Parent then
	      	Puck:SetNetworkOwner(player)
			print ("set")
			local velocity = player.Character.HumanoidRootPart.CFrame.LookVector * 10
			print (velocity)
			Puck.Velocity = velocity
        end
  	end
end)

Oh perhaps the Velocity property is quickly being overwritten by the ROBLOX physics engine. Perhaps you can use a BodyVelocity instance in the puck.

Also is there a reason you are using if Puck:GetNetworkOwner() ~= Hit.Parent then rather than if Puck:GetNetworkOwner() ~= player then? Something looks wrong there.

(P.S. It would be cool if you posted your code in a code block)
image


Puck.Touched:Connect(function(Hit)
	local check = Hit.Parent:FindFirstChild("Humanoid")
	if check then
		local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	    if Puck:GetNetworkOwner() ~= Hit.Parent then
	      	Puck:SetNetworkOwner(player)
			print ("set")
			local velocity = player.Character.HumanoidRootPart.CFrame.LookVector * 10
			print (velocity)
			Puck.BodyVelocity.Velocity = velocity
        end
  	end
end)

One second I’ll get this lol, I was searching it up after I posted the other one sorry.

Edit: There we go
Also, it doesn’t seem to be working as well, the puck moves the same as it would without the BodyVelocity. I’ll screenshot.

image

Try changing the MaxForce property to a higher value. Also it is weird that the Velocity property is such a small vector. Perhaps the method of using a BodyVelocity is inheriently flawed.

If changing the MaxForce property or increasing the Force (LookVector * 10) does not work then I suggest you try using a BodyPosition temporarily (then destroying the BodyPosition?)

Increasing the MaxForce seemed to work but this was my result.

https://gyazo.com/94d260b96579f249b8e2606358703d96

https://gyazo.com/8ff963155e896dd0b7962ac3a87f8fe8

(Seems a little unrealistic)

Should I use a BodyPosition instead?

I just realized this most likely wouldn’t work, if two players were chasing after the puck it would be unfair due to the advantage of shooting the puck. Is there no way other way to do this besides with body movers.

At your current point i’d recommend anchoring the puck and programming the physics yourself artificially using renderstep.

2 Likes

Oh boy lol, would that be jittery at all?

Try using a bodyforce instead and then tween the force so it decelerates. Using bodyvelocity, the speed will accelerate in the beginning, which isn’t realistic at all.

Well, ideally you’d be comparing the change in position every step of your hockey stick and using that to apply a force value to the puck. As long as you had solid calculations every step for forces, it would be the most smooth, because you’re not trying to meld two physics applications together.

What if two players or even three players were to collide with each other and the puck. Should I expect any bugs? Just wondering if it’s worth it to make the change and how difficult it would be.

Thanks, I’ll try that, I think that might work.

1 Like

it is difficult, that is true. because you’re essentially trying to make your own physics calculations for objects. But this does open the window for more opportunities of what you can do with forces, since you’re (artificially) creating them rather than using ROBLOX’s physics engine for it. But if you want to go with a more simple approach, I absolutely recommend what C_onfident suggested, since it uses the same logic (changing acceleration)

1 Like

Thanks everyone, the solution I decided to go with was C_onfidents. Changing the puck to anchored would probably have been too much with an unknown result. It is interesting for anyone else who stumbles upon this.

1 Like