-
What do you want to achieve? Let’s say there is a springconstraint with radius 1, properly set up. Now visually speaking, the spring has an offset of the radius (1) in the “upwards” direction (this is relative). I’d like to compensate for this offset by tweaking the attachment’s position, so the spring visually lines up with where it’s supposed to be
-
What is the issue? Lowering the attachment position by 1Y works fine, until the springconstraint offset is no longer 1Y
here, when you aim up/down the offset starts turning into X/Z offset rather than Y (which wouldn’t be the case if you were aiming completely horizontally), which is problematic for my -1Y solution and requires something like a formula using the camera’s lookvector -
What solutions have you tried so far? My current bandaid consists of an unreadable wall of redundant calculations (see below) which also happens to not properly work (could “work” if I applied more bandaid)
grappleOrientation = camera.CFrame.LookVector
xOrientation = math.abs(grappleOrientation.X)
yOrientation = math.abs(grappleOrientation.Y)
zOrientation = math.abs(grappleOrientation.Z)
xAmount = 0
yAmount = 1
zAmount = 0
if grappleOrientation.Y > 0.25 and zOrientation < 0.45 then
if xOrientation > 0.1 and xOrientation < 0.16 and zOrientation < 0.45 then
xAmount = 0.2 / math.log(1.16+xOrientation, 2.7)
elseif xOrientation > 0.16 then
xAmount = 0.05 + 0.16 / math.log(1+xOrientation, 2.7)
end
if grappleOrientation.X < 0 then
xAmount *= -1
end
if zOrientation > 0.1 and zOrientation < 0.16 and xOrientation < 0.45 then
zAmount = 0.2 / math.log(1.16+zOrientation, 2.7)
elseif zOrientation > 0.16 and xOrientation < 0.45 then
zAmount = 0.05 + 0.16 / math.log(1+zOrientation, 2.7)
end
if grappleOrientation.Z < 0 then
zAmount *= -1
end
end
if grappleOrientation.Y > 0.75 then yAmount = 0.6 end
Setting this up felt like a complete waste of time and I was only wondering if there was a better way to do it. The springconstraint is also only there for visual feedback, it serves no purpose beyond that