Spiderman-like swings

Hello, it’s me once again. I am trying to make a web swing thing like in spiderman. It’s really cool and fast paced. I’ve got the web down but it’s the swinging part which is the problem. I have looked on DevForum and there are numerous topics about this, but all of them are either showcases or not open-sourced. Here is what I have so far:

As you can see, it’s not the smoothest thing ever, and the player is not going really fast. It’s not carrying the momentum to do the crazy swings I want it to. Can anyone help? Here is my current code:

local Rope = Instance.new("SpringConstraint")

game.ReplicatedStorage.CreatePart.OnServerEvent:Connect(function(player, part, mousepos, isholdingdown)	
	if isholdingdown == false then
	elseif isholdingdown == true then
		local A0 = Instance.new('Attachment')
		local A1 = Instance.new('Attachment')
		A0.Parent = workspace.Terrain
		A0.WorldPosition = mousepos
		A1.Parent = player.Character.HumanoidRootPart
		Rope = Instance.new("SpringConstraint")
		Rope.Attachment0 = A0
		Rope.Attachment1 = A1
		Rope.Parent = player.Character
		Rope.Visible = true
		Rope.LimitsEnabled = true
		Rope.Coils = 0
		Rope.Thickness = 0.1
		Rope.Color = BrickColor.new("Institutional white")
		Rope.MaxLength = (player.Character.HumanoidRootPart.Position - part.Position).Magnitude
		local BV = Instance.new('BodyVelocity')
		local char = player.Character
			BV.Velocity = player.Character.Humanoid.MoveDirection * 26
			BV.MaxForce = Vector3.new(1000000,0,1000000)
		BV.Parent = char.HumanoidRootPart
1 Like

Looks like Humanoid control is taking over. Try setting PlatformStand to true on the humanoid to disable it.

1 Like

I can still move my character while in platformstand and also, it makes the character look not stable.

1 Like

Change the max slope angle of the humanoid to 0.

1 Like

How would that help?


It will make the humanoid act slippery.

Would that be helpful for the crazy swings?

Probably. I suggest you try it out.

Alright, also do you know if there is a fix for this? This only happens the first time after you respawn. ONLY the first time.

1 Like

The body velocity doesn’t detect the move direction changed. I recommend using VectorForce instead of BodyVelocity since it uses force and it will create very fast swings.

Had to eat, I’ll try that! Why won’t bodyforce work though?

It would, but it is deprecated. VectorForce is the new version of them.

Oh i see. Also how would I use VectorForce? I’m fairly new to forces. Heres the code:

local BV = Instance.new('VectorForce')
		local char = player.Character
			BV.Velocity = player.Character.Humanoid.MoveDirection * 26
			BV.MaxForce = Vector3.new(1000000,0,1000000)
		BV.Parent = char.HumanoidRootPart

Obviously Ill change the local variable to match with vector force. But how would I use vector force to match what I have and do crazy swings?

Fun fact I just made a system similar to this lol. Whats happening in your video is youre not giving the player enough force, or youre giving the character weird forces (x and z). What I did was use a VectorForce, that pushes on the -z axis and the -y axis. With this, it allows you to create a pendulum shape and makes swinging really smooth. I wanted to make the player rotate with the rope, but I never got it working. If you ever got something that works keep me updated :smiley:

You should look into the documentation for them.

Sure thing :smiley: I’ll keep you posted. Could you share your code about the vector force thing to make it smooth? Also I have seen a post and its only like 10 lines of code or something about rotating to the attachment Ill see if I can find it.

Yeah ive seen that post too, it works half way, but I couldnt get it working for the other half.

For the code, its nothing special. All it does is create an attachment in the player, and clones a vector force. The RootRigAttachment being set as Attachment0, and ApplyAtCenterOfMass is checked. After this, all the code does is basically clone and parent to the HRP

		local force = assets.VectorForce:Clone();
		force.Name = "SpiderForce";
		force.Force = Vector3.new(0,-2000,-5000);
		force.Attachment0 = character.PrimaryPart.RootRigAttachment;
		force.Parent = character.PrimaryPart;

Edit: After reading past messages, I saw you changed the HumanoidState to PlatformStand. For something like this, you dont really want to do that. Unless you use alignpositions or change the CFrame of the player every heartbeat (which i wouldnt recommend because memory usage), it doesn’t make the swing look clean. This is because, in either the PlatformStand or Physics state, the hidden force that keeps the players Humanoid upright is now gone, which will result in what was seen in the videos, the player spinning out of control. With that force, youll be able to either pair it with rotating math, or animations, and the swing will look pretty smooth for code thats as simple as attaching a rope and giving the player a force. Id also recommend leaving a slightly less powerful force after the player lets go of the swing, because if you delete the VectorForce when the player is still swinging, they will lose all the velocity from the swing, so leaving the force there would help with velocity conservation

1 Like

Keeps giving me this error. I am in R6 btw does that have to do with it?

edit: yes it does I changed it to r15 ignore this comment

Pretty sure this is because I was using an R15 avatar, theres something similar for R6 I forgor the name. YOu can always create a new attachment with Instance.new() too

Works really nice except when the player lets go of the web swing and lands on the ground. The player keeps walking forward slightly without any keys touching