Preventing/Opposing Motion

This is a simple but challenging topic, How can I prevent this part from moving? Is it possibe? Only using ApplyImpulse? and yes, it obviously works with the Vector Force.

Here’s my code.

local Part = workspace.Part
local Gravity = workspace.Gravity
local Mass = Part.AssemblyMass

game:GetService("RunService").Heartbeat:Connect(function(delta)
	local CounterGravityForce = Vector3.yAxis * Mass * Gravity
	local CounterForce = -Part.AssemblyLinearVelocity * Mass
	Part:ApplyImpulse((CounterForce+CounterGravityForce)*delta)
end)

is there a reason you cant use any instances?
cause it can be easily done with a simple instance, but doing it script only would be very strange

Ok, then.

Opposing gravity is easy ( Up * Mass * Gravity ). Although opposing motion effectively is much harder, for some odd reason i tried damping it but it didn’t work. Just opposing motion means it now acting in “Zero Gravity” or Newtons First Law becoming true.

-- In a loop...

CounterGravity = Up * Mass * Gravity
CounterMotion = -Velocity * Mass --needs work.

What are you trying to do exactly that requires the part to use ApplyImpulse() instead of just anchoring it?

he’s probably trying to just get it to float??? if thats the case i dont know why he would want ALL motion to cease, unless he just wants rotation, in which case just use an alignposition instance.

Ok, since you guys are so unconscious of the situation, i basically wanted to make a “coyote time effect” or slowed down effect.

Coyote time usually just means a short delay before gravity is applied, and only when running off edges or over short gaps. You wouldn’t use ApplyImpulse for this, or affect any direction besides up/down. More generally, you don’t want to use ApplyImpulse every frame for freezing something, you’ll get instability, at least with Heartbeat or using Stepped with the default adaptive timestep. ApplyImpulse is intended for one-time use to kick something. VectorForce is for applying continuous force over time.

1 Like