Please do not reply to this. I don’t even think this is possible to implement in Roblox because of the physics engine and my very specific use case lol
In Garry’s Mod there is a weapon called the physics gun (derivative of the gravity gun), it allows you to fling stuff around by clicking and holding “unanchored” objects.
Implementing this idea into Roblox seems simple enough, position the mouse’s target in front of the camera. That’s what I did. However, in gmod, it seems to work a bit more complex than that. It keeps its CFrame/orientation & position, yet still follows the camera while keeping those values.
This removes the issue of larger parts covering the entire screen… so I would prefer that over my current method. How would I implement this in Roblox? I have no slightest idea on how the math works here.
Garry’s Mod’s implementation:
This is my current code for moving the part:
partToCtrl.CFrame = partToCtrl.CFrame:Lerp(camera.CFrame + (camera.CFrame.LookVector * 20), 0.25)
I want to know how gmod achieved the effect of keeping the CFrame in video 2.
You can just Manipulate its Position with
Vector3 and use
I need it to keep the orientation & position, and move with the camera. See in video 2 how the wooden box doesn’t move at all when I click on it, but when I start moving the mouse, it moves with the camera and keeps its orientation & original position. Then, in video 1, how it disregards both and floats to the front of the camera.
In very oversimplified terms, I just want a 1:1 recreation of the behaviour in video 2, of which I don’t know how to make.
Sound more like, when the player clicks on a part to select which one to move, the part wont move until player has moved the camera outside the “limit”.
So once a player selected a part, changing the position will start only when player change the current camera position not inmediately after click. And probably theres a “camera limit” measure, to determine when to move the part.
And maybe not changing the CFrame, only the Position as stated before
Can’t you store the part orientation as variable and change it everytime the CFrame also changes? I assume you’re using a loop.
You can add a bodygyro (Ik it’s deprecated but it is very useful) to the item and set the frame to the part’s current frame, then instead of lerping the cframe, just set the position.