I don't understand how one is supposed to get the desired position using vector3

So I was looking through an open-sourced sky-diving script and this specific part of the script AttachmentPosition2 = Vector3.new(0.3,-0.9,0) obviously creates the value for the position that the attachment is going to be in which is likely in the players’ limbs,to which contrails will be added.

But my question is how does the author of the script know that this position will have the attachment in the intended part of the player? Especially when the player’s going to be moving all over the place due to skydiving and that.

1 Like

Now attachments have two things for position, World Position, and Position. World Position is just like the normal Position for any part, it is where in the world the attachment is. But the “Position”, is where the attachment is going to be relative to the position and orientation of it’s parent. So no matter how the character is oriented and what position they are, if the attachment was in their torso it would be in one of their legs.

1 Like

So how did the author know that though? Did he move the attachment in the workspace to the player beforehand or what?

1 Like

This is where vector addition comes into play, since that line will place the attachment somewhere closer relative to the origin 0,0,0, which is not what you want. You want it to be placed in relation to the player’s limb but not accounting for the rotation since attachment’s can’t take CFrames as positions.

For understanding purposes: this code will create 2 parts and will make 1 one of them positioned on another part but offsetted by 5 studs.

local part1 = Instance.new("Part")
part1.Anchored = true
part1.Position = Vector3.new(0, 50, 75)
part1.Parent = workspace

local part = Instance.new("Part")
part.Anchored = true
part.Position = part1.Position
part.Parent = workspace

while (game:GetService("RunService").Heartbeat:Wait()) do
      part.Position = part1.Position + Vector3.new(0, 5, 0)
end
1 Like

It can’t? According to the devhub, it’s stored as a cframe property and according to this other article It states that it has position. Am I misunderstanding something? If so please do enlighten.

But when I take a look at the rest of the script:

local Attachment1D = Instance.new("Attachment",ContrailBodyPart4)
	Attachment1D.Position = AttachmentPosition1
	local Attachment2D = Instance.new("Attachment",ContrailBodyPart4)
	Attachment2D.Position = AttachmentPosition2
	ContrailsD = Instance.new("Trail",ContrailBodyPart4)
	ContrailsD.Attachment0 = Attachment1D
	ContrailsD.Attachment1 = Attachment2D
	ContrailsD.Texture = "rbxassetid://3517446796"
	ContrailsD.LightInfluence = 1
	ContrailsD.TextureLength = 1
	ContrailsD.FaceCamera = true
	ContrailsD.Transparency = NumberSequence.new{
		NumberSequenceKeypoint.new(0,1),
		NumberSequenceKeypoint.new(0.1,0.7),
		NumberSequenceKeypoint.new(1,1)
	}
end

Player:GetMouse().KeyDown:Connect(function(Key)
	if Key:byte() == 119 or Key:byte() == 17 then -- W
		TiltFB = -1
		GlideFB = 2
		Drag = DragRatio*(0.997+DragDiminish)
		if IsFalling.Value == true then
			FreeFallAnimationForward:Play(0.25)
		end
	elseif Key:byte() == 97 or Key:byte() == 20 then -- A
		TiltLR = 1
		GlideLR = -1
		if IsFalling.Value == true then
			FreeFallAnimationLeft:Play(0.25)
		end
	elseif Key:byte() == 100 or Key:byte() == 19 then -- D
		TiltLR = -1
		GlideLR = 1
		if IsFalling.Value == true then
			FreeFallAnimationRight:Play(0.25)
		end 
	elseif (Key:byte() == 97 and Key:byte() == 100) or (Key:byte() == 20 and Key:byte() == 19) then
		TiltLR = 0
		GlideLR = 0
		FreeFallAnimationLeft:Stop()
		FreeFallAnimationRight:Stop()
    end
end)

Player:GetMouse().KeyUp:Connect(function(Key)
    if Key:byte() == 119 or Key:byte() == 17 then -- W
		TiltFB = 0
		GlideFB = 0
		Drag = DragRatio
		FreeFallAnimationForward:Stop()
	elseif (Key:byte() == 97 or Key:byte() == 20) or (Key:byte() == 100 or Key:byte() == 19) then -- A/D
		TiltLR = 0
		GlideLR = 0
		FreeFallAnimationLeft:Stop()
		FreeFallAnimationRight:Stop()
	end
end)


IsFalling.Changed:Connect(function()
	if IsFalling.Value == true then
		FreeFallAnimation:Play(1)
	else
		FreeFallAnimation:Stop()
		FreeFallAnimationForward:Stop()
		FreeFallAnimationLeft:Stop()
		FreeFallAnimationRight:Stop()
	end
end)

Run.RenderStepped:Connect(function()
	local Speed = HumanoidRootPart.Velocity.Y
	local lookVector = Camera.CFrame.LookVector
	
	if AtmosphericPressureInfluence == false then
		DragDiminish = 0
		MinimumAltitude = math.huge
	else
		DragDiminish = -((101.325*((((((86)-(0.00356*(HumanoidRootPart.Position.Y))+459.67)/(459.67+(86)))^5.256))))/101.325)*0.0015+0.0015
		MinimumAltitude = (160000/(1+1.0001^HumanoidRootPart.Velocity.Y))-15000 -- This allows you to slow down safely if you entered the atmosphere with speeds up to 10,000 studs/s
	end

	if Speed <= MinimumSpeed and Humanoid.Sit == false and HumanoidRootPart.Position.Y <= MinimumAltitude and Humanoid.Health > 0 then
		workspace.Gravity = 32.174 -- I used real gravity while making this script. 
		HumanoidRootPart.Velocity = HumanoidRootPart.Velocity*(Drag+DragDiminish)+Vector3.new(GlideLR,1,GlideLR)*HumanoidRootPart.CFrame.RightVector+Vector3.new(GlideFB,1,GlideFB)*HumanoidRootPart.CFrame.LookVector
		Gyro.MaxTorque = Vector3.new(40000000,40000000,40000000)
		Gyro.CFrame = CFrame.new(HumanoidRootPart.Position)*CFrame.Angles(0,math.atan2(-lookVector.X,-lookVector.Z),TiltLR/2)*CFrame.Angles(TiltFB,0,0)
		Humanoid.PlatformStand = true
		IsFalling.Value = true
		Character.Animate.Disabled = true
		ContrailsA.Enabled = true
		ContrailsB.Enabled = true
		ContrailsC.Enabled = true
		ContrailsD.Enabled = true
	else
		workspace.Gravity = InitialGravity
		Gyro.MaxTorque = Vector3.new(0,0,0)
		Humanoid.PlatformStand = false
		IsFalling.Value = false
		Character.Animate.Disabled = false
		ContrailsA.Enabled = false
		ContrailsB.Enabled = false
		ContrailsC.Enabled = false
		ContrailsD.Enabled = false
	end
end)

There’s no vector3 adding to get the position relative to the player’s limb in regards to the attachments, how was it placed in the right position?

1 Like