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:
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.
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
Sure thing 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
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