Welding moving parts inside a tool to a handle

hi devforum !!

I’m currently making a holdable cannon for my roblox game, but I’ve been running into some issues when it comes to welding.

A script i made makes it so the barrel of the cannon adjusts its rotation so that it looks in the same direction as the camera does. (If it’s relevant, it adjusts the rotation using a PivotTo function)

1
The Barrel is welded to the MainBodyPart


The MainBodyPart is welded to the Handle

The issue i’m running into is that, when equipping the cannon, it causes a rather interesting bouncing and flying effect.

My theory (and I’m pretty sure that’s what’s happening) is that, due to the barrel rotating and it being welded to the handle through the MainBodyPart, it ends up rotating the handle along with it.

I don’t know how to fix this. I’ve looked around a bit and couldn’t quite find many threads that could help me alot. I heard the terms Motor6D and HingeConstraints being mentioned, but after looking into these instances I didn’t think they would fix the issue that i’m having. Not welding them would also, obviously, not work, they’d just fall into the void.

Any help is rlly appreciated !! Thx in advance

2 Likes

mmmm ball and socket constraint maybe?

2 Likes

tried it,
unfortunately it just causes different behavior and not the intended… :c

i managed to use hingeconstraints earlier and it fixed the flying and flinging, but it still resulted to some very weird movement, which was very similar to ball socket constraints (what you suggested)

this vid used ballsocketconstraints

i think all i have to figure out is how to let the barrel of the cannon rotate freely without interfering with the handle’s orientation or position

thx alot for replying though, Was happy to read that someone replied to my post earlier today lol

2 Likes

is it a massless? Or and no collisions. Or if you do want the collision try to make it massless and customphysicalproperties all parts to density=0

2 Likes

yea, massless is enabled and collisions are disabled. Again im pretty sure that the problem is that the barrel is moving the handle with it, as they’re welded…

Thanks alot for the reply tho!! I appreciate it!!

2 Likes

instead of welding them, use a different type of constraint maybe? (ball and socket)

(I know i mention this before but I just wanted to clarify what I meant)

1 Like

alright, ill try out different combinations on making them stick together then later, Ill give u an update once i did a bit

1 Like

can’t figure out anything, no constraint combination works

Maybe this line is of importance for something:

barrel:PivotTo(CFrame.new(barrel:GetPivot().Position) * CFrame.Angles(0, math.rad(camAngleX + 90), math.rad(camAngleY)))

that’s the function that changes the barrels orientation, that i mentioned in the beginning of the thread. Maybe i should use another function? not sure, either way, neither hingeconstraints nor ballsocketconstraints seem to have gotten me any closer to fixing anything. I rlly appreciate the help so far though!! i just hope to fix this soon

i don’t know if i’m allowed to do this but i want to bump this thread.
i still haven’t figured out a solution. a person told me to use normal welds but that didn’t help either, it resulted in the same behaviour, ive attached another video of this below

i don’t know what else i can do to fix this? i’m rlly stuck

Hmm interesting…It appears that the entire player is moving wherever you’re aiming at: im thinking you’re going to have to make it mobile on the ground and introduce a raycast, or find a way where in terms wherever you’re aiming and clicking, a projectile will go to that deskganted area: I can show you an idea of how this works with a gun model.

You shouldn’t be setting the rotation of the barrel part directly with PivotTo. You can edit the welds’ or motor6D’s CFrame instead.
Maybe try editing the C1 of the weld between the barrel and MainBodyPart?

What I did with an old rocket system of mine was have an invisible “pivot point” where the barrel’s supposed to rotate from. Then weld any rotating parts, such as the barrel, to that and weld the pivot point to the stationary part (in this case, the handle). Rotate the C1 of the weld between the pivot point and the handle, and all the rotating parts should rotate with it.

2 Likes

Hi, sorry for the late response I was on vacation. Tomorrow when i have access to studio again i will try out both of you guys’ solutions to see if I csn get any closer to fixing this

Thx for the answers, i appreciate it !!

alr. this fixed it
Thank u so much !!! This completely fixed everythign and works flawlessly!!! I’ll keep that in mind next time i’m using stuff like welds inside a tool - i can finally carry on with this game.
Thx again for the help everyone, im happy that this got solved

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.