Hello!
I’m trying to create something similar to a 3D speedometer inside of a moving vehicle model. I want the the speedometer needle to move with the car, but still be able to move independently via script without affecting the rest of the car. This is probably a simple solution but I couldn’t find any resources or help on this anywhere online.
I would just use welds and the C0 and C1 property to create the proper offset on the moving vehicle
(You could also technically use a motor6d which might be easier in a sense)
This could be done with a basic script like:
weld.C1 = CFrame.new(0,0,lengthOfNeedle / 2)*CFrame.Angles(0,math.rad(angleOfNeedle),0)
In a setup where you have a weld with a Part0 of a central piece, and a Part1 of the needle
The exact details of your setup are necessary and the code above likely wont work unless you have the parts oriented exactly like I do, Ill post he orientations below in case you want to base it off of my orientations, but if you want help making the code work with your speedometer model just reply
Both parts have their front vector facing the same direction (the front will be directly downwards on the spedometer) and theyre both facing directly upwards from the face of the spedometer
Hello!
Thank you for the reply!
This solution does work very well by I can’t adjust the needle to be inside of the center dial without it loosing the weld. Do you know any work arounds to this? The end of the needle not being in the center of the dial causes it to pivot weird.
Thanks!
The weld C0 and C1 should determine the offset and position of the needle relative to the center
I intended for the weld to have a natural resting C0 and C1 of:
weld.C0 = CFrame.new()
weld.C1 = CFrame.new(0,0,lengthOfNeedle / 2)*CFrame.Angles(0,math.rad(restingAngleOfNeedle),0)
And a moving C1 of:
weld.C1 = CFrame.new(0,0,lengthOfNeedle / 2)*CFrame.Angles(0,math.rad(restingAngleOfNeedle + angleOfNeedle),0)
I added on the “restingAngleOfNeedle” in case you wanted to have the dial to start/rest at like 20 degrees like a real speedometer
Thanks for the fast reply! The speedometer is working!