Uhhh…I actually don’t know. Could you send the contents of the localscript so I can test this myself?
Uhhh…
I appear to be suffering a problem while looking around. Is this one different than what’s shown in the video?
Okay, I’m probably just stupid, but this is kinda confusing. Gimme a little bit to try to fix this, please. If I can’t, then maybe someone else can.
Ight.
So… we run the RequestCam
that sends a request to the client to share where the camera is looking (LookVector
). Then the LocCam
sends it (roblox doesn’t allow this kind of data to be known by the server (or any other player data) by default so we have to get it somehow).
(btw we get where the HumanoidRootPart
is facing too because while testing it lagged behind if we were to mesure from the BodyRotate
)
BodyRotate
is the brain of it.
We take the Motor6D
that connects the UpperTorso
and LowerTorso
.
function answears(plr,look,origin)
this is where you got stuck i think.
plr: player… obv
look: camera LookVector
origin: HumanoidRootPart
LookVector
(so the script knows just from where it should rotate it from)
We set the Waist
CFrame
by doing this: (look.X - origin.X) / 10
the /10
is to not over rotate.
You are not dumb it’s just a mess. And i thank everyone who helps.
Okay, so, I rewrote a bunch of it, and I think I got something that works well!
Baseplate (1).rbxl (19.0 KB)
Here’s the new version of it. Feel free to modify it however you’d like. If there’s anything I did wrong, lemme know.
Instead of doing a bunch of complicated Vector3 stuff, I opted to just look ahead of where the camera was, and it seems to work good!
Finnaly. Someone who helped.The past 2 months have been worth it.
Looks like it works perfectly. Do you need credit? What was wrong?
I forgot to attach it lol, also wanted to see if I could do something before posting it
Wait…
I mean thx… but it overrotates when turning the whole body.
How do i fix that?
btw uploading on forums is broken
o h hold on, I didn’t actually try moving, lemme see if I can fix that. Sorry!
np… oversights happen
(30CHARLIMITWHY)
Going to sleep.
If i don’t respond… that’s why.
Alright. I’m still trying to figure this out; however, I’m not necessarily an expert with CFrames. I got this to work, though:
Here’s a function tuned to your needs.
--Initialization
local torso = script.Parent:WaitForChild"UpperTorso"
local humanoidRootPart = script.Parent:WaitForChild"HumanoidRootPart"
local OrigC0 = torso.Waist.C0 --store the original C0 value for transformation
--"Runtime"
function answears(plr,look)
local torsoL = humanoidRootPart.CFrame.LookVector
local torsoR = humanoidRootPart.CFrame.RightVector
local torsoU = humanoidRootPart.CFrame.UpVector
--Just the basic vectors, you can tell what they are already.
local camVect = look:Lerp(humanoidRootPart.CFrame.LookVector,0.51)
--Make a vector that doesn't turn you like that girl from the exorcist
local rotY = -math.atan2(torsoR:Dot(camVect),torsoL:Dot(camVect))
--Dot determines how much the target vect faces the torso vectors
--By doing this, we can construct "relative" coordinates as opposed to "absolute" coordinates.
--We can then determine the relative angle from these coordinates using atan2
local rotX = math.asin(torsoU:Dot(camVect))*2
--This also works the same, only this time it's for getting the rotation looking up/down
torso.Waist.C0 = OrigC0*CFrame.Angles(0,rotY,0)*CFrame.Angles(rotX,0,0)
--Sets the waist every step
end
--You could realistically compact this entire function into a couple of lines, but this is just easier to read.
ans.OnServerEvent:Connect(answears)
Adjusting the joints of a motor for the sake of facing something should definitely be a relative value.
Funnily enough, I actually just remembered toObjectSpace exists, and fixed the whole thing. Can’t believe it took me this long.
Baseplate (1).rbxl (19.3 KB)
Your solution looks like it’d also work just as fine, figured I’d post mine though. Added client side lerping and all that fancy stuff.
Allrigh.
@MrMauio @pheonixmario
Let me wake up first, and i’ll try them and see what works best for me, and then i’ll mark the solution.
So the results:
@pheonixmario’s solution broke when trying to port to final product, but still smooth.
So i wanted it to come down to readability and ease of use… then this happened.
So thx again for the help… if you need credit, tell me. I am more than willing to give credit. I’m glad people are out to help, and thank you for your time.
edit: hitfilm (video editor) messed up the quality.
I don’t need any credit, just happy that it works