I’m making a physics based game and I’m having issues with physics (of course). The goal is for the player to be able to launch themselves with an arm to get to places. I just don’t understand why momentum is not being carried upwards. I’m thinking of different ways to solve this issue. Is there a different way to do this?
I still don’t really understand how to make a momentum system with bodymovers.
So in order to do what I want it to, I would have to get the difference in position every frame and determine whether or not to use a bodymover like bodyForce?
Sorry for the delayed response, but here’s some code to demo BodyForce.
BodyForce is really simple
All it does is apply force in a Vector3.
So if we want to push the character up, all we have to do is apply a BodyForce of Vector3.new(0,someValue,0)
(it’s super simple )
-- Example Code
local bodyForce = Instance.new("BodyForce"); -- Creates a new body force
bodyForce.Parent = script.Parent; -- Sets the parent to the part
while true do -- Simple while loop that sets the force then resets it
bodyForce.Force = Vector3.new(0,2000,0);
wait(.5);
bodyForce.Force = Vector3.new(0,0,0);
wait(3);
end
Do note that mass is taken into account, so make sure to make accessories and other parts massless. And trial and error will let you find the best force
I understand how bodymovers work, but how could I implement this into a inertia system?
Would I have to use heartbeat to get the position of the “hand” and get the differences in position to then create a bodyforce to create inertia?
If so, wouldn’t it be better to use bodyvelocity instead?
Ok, that sounds good. Do you happen to know any idea on how to get the power for it? Like would you think the difference in position would be best?
Thanks for the help.
Actually I was just looking at some of the other body movers,
Body thrust might be more interesting. Since with body thrust you can set the location of where the thrust is being applied. I think that might work better actually
Regarding inertia, you can either rely on gravity or script that yourself.
Here’s some more demo code which I used to reduce the force over time.
local RunService = game:GetService("RunService");
local Vector3_new = Vector3.new; -- Caching function for efficiency
local bodyForce = script.Parent:WaitForChild("BodyThrust");
local startValue = 2000;
local decreasePerSecond = 2000;
local resetValue = 0;
local delayBetween = 2; -- in seconds
local elapsed = 0;
RunService.Heartbeat:Connect(function(dt)
if bodyForce.Force.Y < resetValue then
if elapsed > delayBetween then
bodyForce.Force = Vector3_new(0, startValue, 0);
elapsed = 0;
else
elapsed += dt;
end
else
bodyForce.Force -= Vector3_new(0, decreasePerSecond*dt, 0);
end
end)
I’m planning on just moving the center of the character so I think I would use BodyVelocity .
Thanks for the help.
Edit: not BodyAngularVelocity, I ment BodyVelocity
Edit 2: after some experimentation, I believe BodyForce would be the best solution for my problem. Now I just have to work on how to determine the value through VR.