How would I go about scripting a beam with physics

Uhh, raycasting from user mouse??

Your idea is super vague, please explain more.

1 Like

No like a whole web swinging system with beams

Like I said before, raycasting. Using Vector2 and CFrame will help you too.

Can you explain it more procedurally?

I would assume you should use a rope. But if you want to use a beam, you would need to get the mouse position and cast a ray to that point that continues until like 40 studs.

Yes, a RopeContraint: RopeConstraint | Documentation - Roblox Creator Hub

I want the webs to have textures so ropes wont do it for me, plus there an issue with client-server replication and physics

you need a roof, and when u click, make a beam where one attachment is on the roof and the others in in ur character,

tbh, ropes looks more efficent to use in this case. since spider-webs funtions like ropes a bit, where as beam, has no physics

Thats why im trying to script the physics of a beam when I attach it to a fixed point, and I become a human pendulum so to speakWarpedWhichAlbertosaurus-size_restricted

1 Like

Here is a post, use your search engine before creating a post. Making a simple Pendulum Model without physics

(video from post)
https://i.gyazo.com/430f3122ac7ea03f2891e5f921189135.mp4

1 Like

How certain are you this will work and is that a beam in the video and what about bodymovers??

I am 100% sure that will work, no bodymovers just trigonometry.

Can you try to test it out for me and see how it works currently dont have access to my pc right now

1 Like

I am not at my pc either :confused:

1 Like

thats a big oof well have an idea what texture he is using for the beam ?

… There is no texture it is trig.

Read the article first.

PLEASE read the article before asking me.

Dude I meant this part
image
The texture id of the beam

I dont think that article will help me because both the bob and the fixed point need to be anchored, I’m not trying to create my own physics model

I’ve tried my hand at making a Spiderman Web Swinging controller as well, and honestly my first attempt was replicated after that post @recanman sent above.

The whole idea behind creating a pendulum arc/motion for the player so they can feel like they’re swinging from a fixed point is simply constraint.

Spiderman’s web keeps him constrained while gravity acts on him and so he builds up momentum, and so when he released the web that momentum keeps him going in the air until he eventually slows down.

So let’s take a look at this from a game developer’s standpoint.

Firstly, the beam… think of the beam as just an aesthetic it’s not really necessary to get any kind of motion going, what we need to focus on is the player’s character and the anchor point.

Secondly, the anchor point… once you’ve used whatever method you desire to find your anchor point in space, find the distance between that point and your player’s current position

Thirdly, after finding the distance between the two points we need, we have to constrain it… so let’s look at this script

-- a random point in space, 10 studs above the origin
local anchor_point = Vector3.new(0, 10, 0)

-- another random point in space which will be our current player's position
-- it is also 5 studs above the origin, indicating we are currently in the air.
local current_position = Vector3.new(5, 5, 9)

Now what do we want to do exactly? Well we need to constrain the player’s current position to whatever our Constraint Length is, and to put this into perspective, this is the length of our string/web/rope whatever it is.

now let’s say our constraint length is 6, this means that the player’s current position will not be more than 6 studs away from the anchor point

CONSTRAIN_LENGTH = 6

Now, we can actually constrain the player’s current position, and to do that we need to find the player’s relative distance and position from the anchor point.

-- relative player's position, or more so the offset from the anchor point
local relative_position = current_position - anchor_point
-- relative distance
local relative_distance = relative_position.Magnitude

now we want to constrain it by constantly checking the player’s relative distance to ensure that it is no more than 6 studs away.

if relative_distance > CONSTRAIN_LENGTH then
-- we set the new relative position by applying the constrain length's magnitude
 relative_position = relative_position.Unit * CONSTRAIN_LENGTH
-- we apply the new relative_position to the current_position by adding it to the anchor point
-- remember the relative position is simply an offset from the anchor point
 current_position = anchor_point + relative_position
end

So now the player’s current position will be an offset from the anchor point, while taking into consideration the constraint length we desire

Honestly, I feel like there’s more I need to go into detail about but this is the general idea behind making a simple web swinging mechanic, constraints…

I might make a more in-depth post in the Community Tutorial section later, well bye for now

4 Likes

There you go, Syharaa has done it again!
That explains it a bit more.

2 Likes