Hey everyone, I’m trying to make a slider bar that turns a character model for character creation, but I’m having trouble figuring out how to make it rotate properly. The character is already tilted to face the ground and slightly tilted sideways. For reference,
The slider bar already returns a value between -180 and 180 based on how far along it is. I wanna set the part’s Y rotation (I think, I’m not very good at CFrame angles) so that it turns the model based on the slider’s value.
This is what it looks like right now. https://gyazo.com/7d38a037b0e130a1bad0f063ac0e06d5
What I’m trying to do is have it face the floor when it’s in the center, and away when it’s -180 and 180 respectively, everything in between being a linear progression to those states.
However, I’m not able to figure out how to do it. I’ve tried countless things, all of them seem to not work properly. I’ve watched tutorials, read the documentation and I still don’t get it. Can someone help?
A code snippet or two could go a long way in helping you , but at the moment, the speed at which the model is rotating indicates you didnt convert the degrees into radians before rotating the model.
If that is actually your problem, you can convert between the two with
Correct me if I’m wrong, but I’m fairly sure this will give me the same result as in the gif. I believe it will just add the bar’s rotation on top of the old one making it spin around wildly. What I’m trying to do is to just set it as the bar’s rotation.
You’d math.rad the yrot, but I’ve already tried this;; the problem is that I can’t figure out how to get the old default rotation so that it’s facing the way that it is in the picture on top of it working like this.
You can’t use the orientation since it changes to compensate for the strange tilt and no longer becomes viable, and I don’t know how to get it (as a radiant or degree) from the cframe
I would hard code the Y rotation offset you want and add it to the Y rotation calculated via the calculation above as trying to re-calculate the Y rotation via ToEulerAngles may give you incorrect rotations.
You would have to use CFrame:ToEulerAnglesXYZ. I would advise against using this function if possible though because it recalculates the angles to the best of its ability, but doesn’t always get it completely right.
Alright, the idea I had worked. I simply lerped based on the percentage of where the bar was located. (completely to the left is -1, completely to the right is 1). I saved the default value then the value where it is rotated 180 degrees. I then simply lerped using the percentage. https://gyazo.com/29a7d8ccf0ec4583d01ebb4ae0b9f0fe I’m not gonna mark this as a solution cause I feel like marking myself as a solution and it counting towards the list of solutions on my profile is kind of cheap. never mind
Do it anyways, other people might have an issue in the future and come to this thread eventually. There’s also people who’ll come here thinking this is unresolved.