--getting direction to send character front-up
local impulseDirection = (attachmentCFrame.LookVector*.5 + Vector3.new(0, math.sin(math.rad(60)), 0)).Unit
self._owner.Character.PrimaryPart:ApplyImpulse(impulseDirection * mass * force)
print(impulseDirection * mass * force) --1157051, 2004071, 0 (when character is facing +X)
even tho I set the force very high, it doesn’t work. What am I doing wrong? PrimaryPart is the HumanoidRootPart, mass is the total mass of the character, force is a number. Character is not scaled.
This is a character, so I assume this is some sort of knockback script. This would always frustrate me. I had to set the humanoid to platform stand, but I think now this is a better method: HumanoidStateType | Documentation - Roblox Creator Hub
Basically the character is being controlled by the client, so to apply physics like this to it you need to set the humanoid’s state to something that allows this. Afterwards you can wait a second and set it back to normal, or maybe find a fancy way to detect when the impulse is done.
I have to fire client to change state and then assume that player already did and continue? Or another way allow client to handle ApplyImpulse? (Which will be delayed because of ping.) What I understand is I should use vector force to do it instantly. Whats the point of apply impulse than?
ApplyImpulse is meant to be used on server-side only, if you really need something to simulate a knockout im pretty sure LinearVelocity can simulate a knockback (or the method as bubbybumble) might be your answer since our character is tagged as Client and completely controlled by player, that’s why ApplyImpulse refuses to do it.
that was the first thing I tried, does not work, im using vector force instead. It is working fine, It seems impulse is just vector force that is applied for dt. Also apply impulse is a function that can be called by server or local script for instances that belongs to the player, but I guess requiring humanoid state change.
It’s always weird to me, I’ve never quite figured it out. Usually, I have the most luck using a body velocity instance (or whatever the non deprecated version of it is now) and having it stick around for about half a second. That way it really makes sure the player is being hit away.