AlignPosition messing things up

I am trying to use alignPosition to keep the frisbee at a height of 4. In the first video I set it so the script waits .1 seconds before it enables the alignPostition. When I do that, it works, but it dips for a second which is undesirable. In the second video I make it so the script instantly enables the alignPosition. When I do this, the frisbee does not act how I want at all. You can see it loses all of its velocity for some reason. When the frisbee is thrown I set its position to a little in front of the player and at the height of 4 so in theory this should not be a problem.


Here are the properties

function shot(direction)
	brake=true
	animationInProgress=true
	
	local directionMultiplier=1
	local vectorForceApplied=0
		
	local character=frisbee.Parent
	local player= game.Players:GetPlayerFromCharacter(character)
	local humanoid=character:FindFirstChild('Humanoid')
	local spawnPos = CFrame.new(character:WaitForChild("HumanoidRootPart").CFrame.Position)
	character:WaitForChild("Humanoid").WalkSpeed=0
	
	--find target point
	local mouseHit = game.ReplicatedStorage.getMouseLocation:InvokeClient(player)
	local angle=math.atan((mouseHit.Z-spawnPos.Z)/(mouseHit.X-spawnPos.X))

	local x=math.cos(angle)
	local z=math.sin(angle)
	print(math.deg(angle))
	--determine power level
	if bluePerfects==3 and b==-1 or redPerfects==3 and b==1 then
		x=x*300
		z=z*300
		
		if b==1 then
			redPerfects=0
		elseif b==-1 then
			
			bluePerfects=0
		end
		
	elseif timer<.1 then
		x=x*blue
		z=z*blue
		keypoints=greyKeypoints
		print("early")
	elseif timer<purpleWindow then	
		x=x*purple-((.1/timer)*50)
		z=z*purple-((.1/timer)*50)
		keypoints=purpleKeypoints
		
		if b==1 then
		redPerfects+=1	
			
			
		elseif b==-1 then
			
		bluePerfects+=1	
			
		end
		
	elseif timer <blueWindow then
		print("bluex="..x)
		x=x*blue-((purpleWindow/timer)*35)
		z=z*blue-((purpleWindow/timer)*35)
		keypoints=blueKeypoints
		
	elseif timer<grayWindow then
		x=x*gray-((blueWindow/timer)*20)
		z=z*gray-((blueWindow/timer)*20)
		keypoints=greyKeypoints
		
	else
		x=x*50
		z=z*50
		keypoints=greyKeypoints
	end
	
	print("timer=" ..timer)
	playAnimation(character)
	wait(.25)
	mesh:Destroy()
	if intermediate then
		intermediate:Destroy()
	end
	
	--set velocity
	frisbee.Parent=game.Workspace
	frisbee.Handle.AssemblyLinearVelocity=Vector3.new(x*b,0,z*b)
	frisbee.Handle.CFrame=CFrame.new(spawnPos.X+(b*5),4.469,spawnPos.Z)
	
	
	
	print("x="..x)
	print("z="..z)

	--Curve
	
	
	if direction=="right" or direction=="left"then 
		
		if direction=="right" then
			directionMultiplier=-1
		end
		vectorForceApplied=-1*directionMultiplier*b*math.abs(math.deg(angle)*20)
		if math.abs(vectorForceApplied)>maxVectorForce then
		vectorForceApplied=-maxVectorForce*b
		end
	vectorForce.Force=Vector3.new(0,0,vectorForceApplied)
	vectorForce.Enabled = true
	print("vector force=")
		print(vectorForceApplied)
		
		end
--intermediate
	intermediate=Instance.new("Part")
	intermediate.Name="Intermediate"
	intermediate.Parent=body
	intermediate.CFrame=body.CFrame
	if direction=="right" or direction=="left"then
		intermediate.Orientation=Vector3.new((vectorForceApplied/maxVectorForce)*45,0,0)
	else
		intermediate.Orientation=Vector3.new(0,0,0)
	end

--intermediate.Orientation=Vector3.new(-45,0,0)
	local weld = Instance.new("WeldConstraint")
	weld.Parent = intermediate
	weld.Part0 = body
	weld.Part1 = intermediate

	intermediate.Transparency=1
	intermediate.CanTouch=false
	intermediate.CanCollide=false
	intermediate.Massless=true

	local rotationAttachment=Instance.new("Attachment")
	rotationAttachment.Name="RotationAttachment"
	rotationAttachment.Parent=intermediate
	rotationAttachment.Orientation=Vector3.new(0,180,90)
	--rotationAttachment.Position





	--apply frisbee skin
	mesh=game.ReplicatedStorage.Frisbees.tronfrisbee:Clone()
	mesh.CustomPhysicalProperties=PhysicalProperties.new(.1,0,0)
	mesh.CanTouch=false
	mesh.CanCollide=false
	mesh.Massless=true
	mesh.Position=intermediate.Position
	mesh.Size=Vector3.new(6,6,1)
	mesh.Parent=body


	local hinge = Instance.new("HingeConstraint")
	hinge.Parent = intermediate
	hinge.Attachment0 = rotationAttachment
	hinge.Attachment1 = mesh.Attachment

	hinge.ActuatorType="Motor"
	hinge.AngularVelocity=-15*b
	hinge.MotorMaxAcceleration=15
	hinge.MotorMaxTorque=15
	
	
	--stop spin
	frisbee.Handle.AlignOrientation.Enabled=true
	frisbee.Handle.AlignPosition.Enabled=true

	


	--Trail
	--(0,0,+-2.5)
	local trailAttachment1=Instance.new('Attachment')
	local trailAttachment2=Instance.new('Attachment')
	trailAttachment1.Parent=intermediate
	trailAttachment2.Parent=intermediate
	trailAttachment1.Position=Vector3.new(0,0,2.5)
	trailAttachment2.Position=Vector3.new(0,0,-2.5)
	trail.Attachment0=trailAttachment1
	trail.Attachment1=trailAttachment2
	
	trail.Enabled=true
	trail.Color= ColorSequence.new(keypoints)
	if keypoints==purpleKeypoints then
		trail.Lifetime=.5
	else 
		trail.Lifetime=.3
	end
	
	
	
	--Set collision group
	frisbee.Handle.Body.CollisionGroup='frisbee'
	for _, v in pairs(character:GetChildren()) do
		if v:IsA("Basepart") then
			v.CollisionGroup = "None"
		end
	end
	frisbee.Handle.Body.CanTouch=false
	frisbee.Handle.CanTouch=false
	wait(.3)
	for _, v in pairs(character:GetChildren()) do
		if v:IsA("Basepart") then
			v.CollisionGroup = "Default"
		end
	end
	frisbee.Handle.Body.CanTouch=true
	frisbee.Handle.CanTouch=true
	
	character:WaitForChild("Humanoid").WalkSpeed=40
	animationInProgress=false
	
	

end

Could you show your code? This could also be a NetworkOwnership problem.

1 Like

Ya I will throw it in the orignal post

This is because AlignPosition sucks badly. Raise the responsiveness and tween the position instead of setting it. For some odd reason AlignPosition pushes itself with physics but this includes wind drag as well with the aerodynamics update. So you’ll have to tween the position.

1 Like

What do you mean by tween the position?

I thought you were moving it using align position. Try clicking the part its in and disable EnableFluidForces and see if that works out. If not, bump up the responsiveness or enable RigidityEnabled

I disabled FluidForces and i set the responsiveness to max. I can’t enable rigidity because then I set it to just the Y axis, so i set the MaxAxesForce for Y to a billion but it still does the same thing.

Honestly. I’m not sure then I’d have to mess around with it.

I think the second one breaks because of network ownership. AlignPosition should function like the old bodymovers now.

Try this: right after parenting the frisbee to workspace, loop through all its parts and set the network owner to the server for each part.


frisbee.Parent=game.Workspace
-- set network owner 
for _,obj in ipairs(frisbee:GetDescendants()) do 
	if obj:IsA("BasePart") then 
		obj:SetNetworkOwner(nil)
	end
end
-- continue
frisbee.Handle.AssemblyLinearVelocity=Vector3.new(x*b,0,z*b)
frisbee.Handle.CFrame=CFrame.new(spawnPos.X+(b*5),4.469,spawnPos.Z)

Also, this set of properties for AlignPosition is what I generally use:
image

Give it a go and let me know if it works

1 Like

I tried adding that to the script and using your properties but it still does the same thing.