local part = Instance.new("Part")
part:ApplyImpulse(Vector3.new(50, 0, 0) * part.AssemblyMass)
And we expect that part will have deltaPosition of Vector3.new(50, 0, 0) after one second.
But when I try to do the same thing with character, meaning taking mass of the whole model and applying impulse to HumanoidRootPart, I don’t have the same behaviour. Instead character goes much further away.
How do I get the standard behaviour?
Here is a project that you can use:
Press “F” to apply impulse to Vector.new(50, 0, 0) to Character.
you are summing up AssemblyMass times the character model has BaseParts - which is wrong
AssemblyMass property is ALREADY total mass of the whole model combined
notice reporting masses separately for parts which belong to the same assembly and are effectively welded together makes no sense anyway - at no point in time the engine and collision solver will treat them as separate bodies
also notice, Workspace:FindPartOnRayWithIgnoreList is deprecated
Guess how much? 9322.8037109375, 0, 0 which is an obsured amount!
You could do this instead:
local vectorDirection = character.PrimaryPart.CFrame.LookVector -- could change it to any other side:
local multiplier = 3
local force = vectorDirection * getMass(character) * multiplier
character.PrimaryPart:ApplyImpulse(force)
it will result in: -42.9747428894043, -0.000009481736924499273, -557.7149658203125 in force which is less than whatever the amount was above.
which will move the character slightly to the front and is not too strong
Thank you so much for your comment about “AssemblyMass”. I didn’t understand this detail before.
About Workspace:FindPartOnRayWithIgnoreList: nvm, I just put random model into the project, it’s not really related to the question.
I don’t exactly understand what you were saying about “separate bodies”. Probably you meant that applying impluse to HumanoidRootPart not the same thing as applying impulse for each part or something like that. I get it, but even if we change AssemblyMass in my code to just Mass you will see that deltaPosition is not even near to be Vector3.new(50, 0, 0). Character is barely moved which I find to be strange. In my understanding yes, it wouldn’t be exactly 50 studs away, but something near.
How do you suggest then to use :ApplyImpulse() with characters without using some tricky constants? Really apply impulse to each part? Or the best option is to find right constant?
I see, but the problem with that is that we are using some random constants. I believe it’s better to fully understand what physics constructions we have in engine and how they work. For example, if I understand how :ApplyImpulse() works, I am able to fully understand how exactly part moves after applying impulse which gives me more freedom. You, in contrast, currently just trying to have some multiplier basically for any construction that you ever face which is simply not reliable.
So basically when we do :ApplyImpulse(mass * [some vector]) we expect that after one second part will have position startPosition + [some vector]. That’s how it works for part.
I understand that if you write HumanoidRootPart:ApplyImpulse(something) you will have impulse applied to character. Question how to measure the impulse that will be applied.
Unfortunately for character it is not true that applying impulse mass * [some vector] will lead to character having position startPosition + [some vector] after one second. And I am trying to understand, well, then how it will be affected.
Yes, you apply impulse. But how I understand, you don’t understand what number you pass as JumpImpulse. You just chose some random constant that is looks okey for your project and you were not getting this constants according to documentation of how method works. That’s my vision, but I could be wrong since I am myself trying to understand it now.
Because if your logic was true, it would mean that applying impulse Vector3.new(50, 0, 0) will lead to moving your character to position + Vector3.new(50, 0, 0) after one second which is not true.
Also in physics we just have a formula p = mv with p - impulse, m - mass, v - speed. It’s reasonable to have an api where you need to pass mv as an argument and not just v for that reason.
Okey, no problem, Let it be your way. If you can prove that applying impulse Vector3.new(50, 0, 0) will lead to character having position startPosition + Vector3.new(50, 0, 0) after one second, I will agree with you. Because it’s what you are saying now.