The only really important line is the last one. Whenever I try to add velocity to the gibs, they go flying in one direction together, as seen here (Blood warning!):
Am I doing something wrong (Probably)? ApplyImpulse() has little to no documentation about it so my assumption is that it applies the force towards a position that I set. If there is a better way to do this please tell me
I don’t think it’ll do any difference, and it’ll probably make it less optimised, but would you mind doing this just to try it?
local tempgibs = {}
for i=0, amount do
tempgibs[i] = gibs[math.random(#gibs)]:Clone()
tempgibs[i].CFrame = CFrame.new(ray.Position) + Vector3.new(0, 4, 0)
tempgibs[i].Parent = game.Workspace.Map.Gore.Gibs
end
for _, gib in pairs(tempgibs) do
gib:ApplyImpulse(Vector3.new(math.random(-400, 400), math.random(4, 20), math.random(-400, 400)))
end
Again, I doubt this will do anything, but it’s worth a shot. ApplyImpulse is a weird method, it has virtually nothing on it. If this doesn’t work I’d recommend trying VectorForce or another constraint like that.
This gave the same result. I’m suspicious towards the vector3 argument. Anyways, Ill try using a VectorForce to move it and see how it goes since that has some documentation and ill show the result tomorrow.
ApplyImpulse applies a force that you input (which is a Vector3). It does not make your parts go towards that Vector3 as you suspect. It’s like setting .AssemblyLinearVelocity on a part. You aren’t setting an end position, you’re just setting a force.
The result is the same, All of them get flung in the same direction. This is what the output console looks like:
The vector that is inputted IS random. If you want to see the entire function that handles spawning gibs, tell me, since it spawns all of them at the same position. Ill try other people’s solutions in the meantime
Hey, I took a look at the VectorForce constraint. I ideally don’t want to use it since I’d have to involve task.wait() in my code to create the effect of an impulse. Although this could work, I’d much prefer applying the force through code (only) and without using task.wait() rather than having to create a constraint since this code runs for every gib part.