Hello, I’m trying to make a custom collision where the force of a collision between an obstacle and the player is amplified and applied after a short delay.
Is there a way to get the force of a collision so that I can modify it or simulate it?
Hello, I’m trying to make a custom collision where the force of a collision between an obstacle and the player is amplified and applied after a short delay.
Is there a way to get the force of a collision so that I can modify it or simulate it?
Is there really no answer to this? Every other engine provides this with the collision event, why is Touched so limited? Am I expected to re-write the whole collision engine to make this work???
So, Objects have .Velocity property.
You can compare the part and the players velocity to find the force.
This does not provide the hit direction in any way, even worse, if i get hit by a fixed rotating object, there isn’t even a velocity to compare this to.
You can use position to determine hit direction, and use velocity to determine the force.
Depending on how you have your rotating parts set up, There is RotVelocity which in combination with Position and Orientation would be able to determine the force and hit direction.
This’ll require a bit of math that I’m not sure I’m able to provide properly.
So what you are thinking of is called net force subtraction. The way to do this in roblox is on a touched event check the objects velocity at collision. Then divide that by their mass’s That was the force outputted on that part assuming both are unanchored. So for example if the object colliding had a velocity of 90,0,0 on collision and had a mass of 1 and the stationary object had a mass of 2 it had a net force of 45,0,0 on that object. I shall say if you want a absolute number get the magnitude of those vector units - Coder Husk
If the object that’s colliding is a Player this becomes problematic, since players don’t get a real force applied to them and their walkspeed make things completely entropic. Pheraps i could fix this by making a part on a different collision group always teleport to the player on RenderStepped and use that as my collision velocity, but this is such a clunky way to do this.
Internally Roblox has to calculate the penetration vector in order to make physics work, it would be so easy to expose the value in the Touched event, that would make so many things easier.
Why would player velocity be related to entropy?
I’ve tested it out, upon collision, the player’s velocity is different than that of an object hit in the same spot by the same object (Of the same shape, of course). I believe this has to do with how the humanoid physics are calculated, they are much more stiff. I ran the same test while walking, the result was even further from the object collision simulation, and i couldn’t get any consistent result, it just felt like entropy
Remember mass is calculated by square area
Is there a need to include the humanoid’s mass in the formula? Perhaps you could remove the humanoid’s mass entirely from it, and replace it with an approximation; this would fix that part of the problem.
Objects have a property known as Velocity
. It’s a vector having XYZ values. Logically speaking, what you can do is get the length of the vector using Magnitude
and take it as your collision force.
I’ve similarly tried, while attempting to make a scripted suspension.
Where on collision, it finds the differences between the velocities part hit, and itself. I have a few ideas of how it could work, (this is just an outline and needs refining)
For my examples, assume the part is a wheel and you need to derive the forces acting on it (for simplicity).
If we use a ray projected from the part to the part that is hit, to find the plane of intercept, that is, the angle between the faces of the 2 parts that collide, and derive a resultant force.
Another proposed solution may be to use CFrame:ToObjectSpace(), assuming the part’s X and Z orientation follows the rest of the body it is bound to. You would first likely try to get a unit of the vector, to simplify any calculations (like finding the angle of intercept), then from there calculate the distribution of forces along the 3 axis.
For example, if your Y position is lower, like if the surface is below the object, the vector of the force is pointed upwards, likewise if the Y position is higher, the vector of the force would be pointed more backwards.
Other than that I don’t really think there is much more I can think off.
Unless you can tap into the physics engine used by constraints such as spring constraints, the options are pretty limited.
just calculate the change in the overall momentum of both objects over unit time to get the force.
AssemblyLinearVelocity is very inconsistent. It cannot be checked on collision and be hoped to return a consistent value.
Especially if you are looking for velocity on 1 World Axis. Say Y. If you wanted to check if someone has fallen at a high speed, you’d raycast downwards and check for hrp’s AssemblyLinearVelocity.Y, well this value is very very very inconsistent. I tried adding a longer ray, to make sure that I wasn’t checking the velocity AFTER the ground puts a stop to the player, and it still returned the same results.
Whats the soloution other than checking AssemblyLinearVelocity because im also getting very inconsistent results.