Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to rotate character while anchored?

So im making a flight script and everything works fine except one thing which when the character is sitting idle in the air i anchor it so it doesn't fall out of the sky and so when i do that i cant use bodygyro on it anymore to keep the HRP and camera locked kinda like a fixed third person. and so im trying to see if theres some way i can lock the camera behind the HRP and have the same effects as using body gyro does but while the HRP is anchored?

this is a small part of the script which im using to get that third person effect:

while Flying == true do 
	local Gyro = Instance.new("BodyGyro",HumaoidRP)
	Gyro.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
	Gyro.D = 0
	Gyro.P = 10000
	
	Gyro.CFrame = Camera.CFrame
end

is there someway i can use cframe without body gyro maybe to lock the camera behind the HRP(HumanoidRootPart)?

1 comment

0

CFrame.Angles

1 answer

✓ Accepted answer

A good way to mitigate the effects of gravity is to add a body force that is equal and opposite to that of gravity so you won't have to anchor the character.

function GetMass(Character) do
	local Mass = 0	
	for i,v in pairs(Character:GetChildren() do
		if v:IsA("Basepart") then
			Mass = Mass + v:GetMass()
		end
	end
	return Mass
end

local BodyForce = Instance.new("BodyForce", Character.PrimaryPart)
BodyForce.Force = Vector.new(0, GetMass(Character) * 196.2, 0)

Another way is to just unanchor, apply CFrames then anchor it without using any waits and the character won't move at all in that period.

1 comment

0

thx for the help, the script wasnt exactly the answer but the idea of pushing the character up against the gravitational force at the same time making it lock in space without being anchored solved my question and i was able to script it.

This discussion is preserved as it was. New answers, comments, and votes are closed.