I’m trying to make a pet system in which players can obtain pets and equip them.
The Problem
The problem is that whenever the pets are equipped (using BodyPosition + BodyGyro), they sometimes fall on other player’s screens. I cannot figure out the problem as all parts inside the pet are unanchored, correctly welded and welded to other unanchored parts, non-cancollide, and are updated on Heartbeat. The network owner of the PrimaryPart is set to the player, so I control the pets on the client.
Some things I have attempted to solve this issue is:
- rewelding the pet
- toggling massless/non-massless to see if that affects the movement
- rewriting my script
Here is a screenshot of the PrimaryPart’s properties:
A video of my problem:
If anyone can contribute to solving this issue, please comment.
Thanks, Enclamatic.
4 Likes
Where are your BodyGyro
and BodyPosition
patented to? Could you show me a heirachy of the model during play test mode to that welds are correctly welded and the body forces are still parented? Also when WeldConstraints
might be an issue, go to Model > Show Welds to view the welds.
1 Like
Both the BodyGyro and the BodyPosition are parented to the PrimaryPart of the pet.
Hierarchy of the model:
When I enable Show Welds
, the welds are correctly set and everything is connected together.
1 Like
Are your forces strong enough?
1 Like
Hello, I guess you need to set BodyGyro’s MaxTorque to higher values and do the same thing with BodyPosition’s MaxForce.
1 Like
Both the MaxTorque and MaxForce are set to math.huge
1 Like
How would I determine that? Please explain
We asked the same question.
Try to use weld script, I think that would help.
I hate WeldConstraints, you can’t predict them.
I have tried using ManualWelds and WeldConstraints, however both do not solve the issue.
1 Like
Is it possible to show us your script?
Or maybe the part when it comes to asign position and rotation
I use a framework known as AeroGameFramework. Here is when the script assigns the force values and here is when it updates the pet (on heartbeat)
Assigning force values:
function CharacterPets:Initialize()
self._bodyPosition = Instance.new("BodyPosition")
self._bodyPosition.Parent = self._primaryPart
self._bodyPosition.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
self._bodyPosition.D = 750
self._bodyPosition.P = 25000
self._bodyGyro = Instance.new("BodyGyro")
self._bodyGyro.Parent = self._primaryPart
self._bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
self._bodyGyro.D = 600
self._bodyGyro.P = 13000
end
Update on heartbeat:
function CharacterPets:_update()
local root = self._character:FindFirstChild("HumanoidRootPart")
local humanoid = self._character:FindFirstChild("Humanoid")
if (root and humanoid) then
local regularOffset = self._walk and Vector3.new(0, -humanoid.HipHeight / 1.5, 0) or Vector3.new(0, 0, 0)
local bodyPos = (root.Position + self._offset) + regularOffset
self._bodyPosition.Position = bodyPos
if (humanoid.MoveDirection == Vector3.new(0, 0, 0)) then
self._bodyGyro.CFrame = CFrame.new(self._primaryPart.Position, root.Position)
else
local animationOffset = self._walk and Vector3.new(0, math.sin(tick() * 15), 0) or Vector3.new(0, 0, 0)
local rotationOffset = self._walk and CFrame.Angles(0, 0, math.rad(math.sin(tick() * 5) * 15)) or CFrame.new(0, 0, 0)
self._bodyPosition.Position = bodyPos + animationOffset
self._bodyGyro.CFrame = CFrame.new(self._primaryPart.Position, self._primaryPart.Position + root.CFrame.lookVector) * rotationOffset
end
end
end
1 Like
Not sure, but you have -Humanoid.HipHeight/1.5
in regularOffset, maybe that breaks it?
Also, math.sin(tick() * 15)
can break it, since sinus can be negative.
1 Like
So basically, self._walk
is a variable I assign to each pet class to determine whether or not the pet “walks”. regularOffset offsets the pet on the ground so the pets that walk will walk on the ground, so I’m not sure how that breaks it because it happens to pets that fly too (each pet).
1 Like
I use math.sin(tick() * 15)
to make a wobble effect on the walking pets, so it should purposely go negative so the wobbling effect can go back and forth.
1 Like
I can’t give any goos ideas, I am sleepy. I hope you will find answer before I get back.
1 Like
That’s fine, thank you for helping!!
1 Like