Hello everyone! I’m trying to create a carrying system to my game, but got no idea how.
What do you want to achieve?
A carry system that when you click an object it teleports the object to the player, giving the illusion that he is carrying it. The player can only carry a limited amount of weight and the carried obcets shouldn’t collide themselves.
Here’s an example from another game:
Do you have something already done?
Quite yes… I already set up some test meshes with a NumberValue indicating the “weight” of the object and a ClickDetector
I’ve also done a simple script on StarterCharacterScripts that checks the weight that the player is carrying:
local Weight = script.Parent.Value
script.Parent.Changed:Connect(function(weightValue)
Weight = weightValue
if Weight == 4 then
script.Parent.MaxWeight.Value = true
else
script.Parent.MaxWeight.Value = false
end
end)
Basically, all I need now is learn how to make the multiple objects follow the player camera without them colliding. Any help would be highly appreciated.
For the collision issue, you can just disable CanCollide on everything that is being carried. And for the animations of them gravitating towards the player, you can use TweenService. Finally, in order to make it follow the character, you can use a weld to either the camera itself, the character’s head or its arms (depending on what perspective your game is played from).
Oh I see. For that you want to add an offset to each carried item so they are not directly in the middle of the camera and inside each other using the C0 property of the weld. C0 is the offset of Part1 from Part0, so it should be the distance between the thing you are holding and your head.
You have to play around with the value to find one that works.
For example,
weld.C0 = CFrame.new(0, 0, 1)
will mean that Part1 is 1 stud behind Part0.
1,0,0 will mean Part1 will be 1 stud to the right of the head, and 0,1,0 will mean 1 stud on top of it. You can calculate these values based on the size of the object or you can use predetermined values that will work for every item in your game.