So I have created a beam from my players position to a fixed point, but the problem is the beam doesnt really have any sort of physics and I’m looking to make something like the bloxverse web swinging.
You could try applying a velocity based on the distance of the beam and direction of the beam relative to the character
How would I do this in actual code, could you explain?
I’ll do an example in studio and show you.
Oh thank you I really appreciate it man Ill wait here patiently
As @cjjdawg this can be achieved with BodyMovers. I created a quick proof of concept using BodyPosition instead of BodyVelocity, because I think it might be better for this task.
Without fine tuning the forces, this is the result
Code I used (LocalScript in StarterCharacterScripts - BodyMovers are replicated to the server automatically, so you don’t need to worry about that)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Mouse = Player:GetMouse()
local BodyPosition
Mouse.Button1Down:Connect(function()
BodyPosition = Instance.new('BodyPosition')
BodyPosition.Position = Mouse.Hit.p -- endpoint of your beam
BodyPosition.Parent = Character.HumanoidRootPart
end)
Mouse.Button1Up:Connect(function()
BodyPosition:Destroy()
end)
BodyPosition has some properties that you can mess around with, P and D. These aren’t explained super well in the wiki, so it may be hard to get the proper result, but in general its better to have a rather high P (power) and rather low D (dampening).
@PlayingRobIoxStudio Do you still me to do it? I was going to do something similar to this.
yes id love to still see your way please
thank you mayor ill keep this is mind
So Ive tried this method you showed and it seems the force isnt strong enough to bring the player to the end of the beam
That’s because I didn’t change any of the BodyPosition’s properties.
That said, I’ve actually been having a bit of fun with this myself because I’m bored and I’ve actually been working on this just for the fun of it.
I’ve changed the P and D values to make the swinging seem a bit better, so
Mouse.Button1Down:Connect(function()
BodyPosition = Instance.new('BodyPosition')
BodyPosition.Position = Mouse.Hit.p -- endpoint of your beam
BodyPosition.P = 10e20
BodyPosition.D = 750
BodyPosition.Parent = Character.HumanoidRootPart
end)
If this still isn’t how you want it to react, can always change P and D. Remember, P should be high while D should be low.
Yeah I used those same exact properties and this is the result Im getting
What is a vector force exactly?
I’m working with just the default character and physics, so I think it might be a problem with your falling script. It looks like its conserving momentum and moving forward, so maybe however you’re doing that is messing with the BodyPosition.
Wait i made some mistakes in the code fixing in studio
Yeah, that’s definitely it. BodyMovers are really just applying a force, which is a function of Mass * Acceleration. A greater gravity means a greater downward acceleration for the BodyPosition to overcome.
I multiplied to BodyPosition properties by workspace.Gravity/196.2
(default gravity = 196.2), and the behavior is more or less the same in a higher gravity.
Mouse.Button1Down:Connect(function()
BodyPosition = Instance.new('BodyPosition')
BodyPosition.Position = Mouse.Hit.p -- endpoint of your beam
BodyPosition.MaxForce = BodyPosition.MaxForce * (workspace.Gravity/196.2)
BodyPosition.P = 10e20 * (workspace.Gravity/196.2)
BodyPosition.D = 750 * (workspace.Gravity/196.2)
BodyPosition.Parent = Character.HumanoidRootPart
end)
Uhh, its very buggy now and shoots me right through the baseplate
Uh, that still looks like a problem with the falling script. Try without animation or anything, and see how it works.
Working with physics absolutely sucks and is really just a matter of trial and error until you find the right numbers to do stuff.
Hm, Im pretty sure it has nothing to do with the animation, I’m certain of this well I guess Ill have to trial and error, thanks for the help both of you