Hi so I’m trying to get this dinosaur model behind this target character:
But as you can see from the above picture, the angle and the exact position is a bit messed up, I’m sure the solution is simple but the only way I tried tackling it was to use BodyGyro as apparently MoveTo is not completely accurate.
local cf = Target.HumanoidRootPart.CFrame * CFrame.new(0, 0, 3) -- Three studs behind the target's hrp.
Character.Humanoid:MoveTo(cf.p)
CFrame.lookAt(Dino.HumanoidRootPart.Position, Target.HumanoidRootPart.Position)
-- basic gist of all the CFrame stuff, not much
Would appreciate if anyone can tell me how to make it completely accurate so that the dinosaur’s humanoid root part (which is aligned correctly) is directly facing the target’s back, 3 studs away.
^ To clarify this, I mean the dinosaur, from wherever it is on the map, would have to move to the target and end 3 studs behind their back.
The solution seems to be in your own first post. Humanoid:MoveTo only causes the humanoid to move towards a location it’s aware of on the server. It also doesn’t rotate 100% accurately, as you said, due to some dampering.
BodyGyro is the solution you’re looking for and it’s one I personally use for combat NPCs to cause them to face the right direction. It only needs MaxTorque on the Y axis (X and Z should be 0 to avoid odd flipping on the other axes).
After the MoveTo has finished, simply have it face the correct location.
The MaxTorque must be able to move the mass of the assembly system (the connected parts of the root part) and the power (P) is how much force to apply to rotate the part to the designated goal. In short, you have to play around with these numbers in the live game and find some that satisfy your needs.
Almost never will you need to adjust the dampening (D). Start with a relatively high MaxTorque on the Y axis (something like 40000) and play with the power.
It’s still not centered but the BodyGyro seems to be a start, what could the possible reason be for it not being completely straight? The position of the Dinosaur’s HRP would be exactly 3 studs from the target’s HRP yet it doesn’t seem to be working.
I can’t decipher from just words, unfortunately. To protect your model’s proprietary design, could you remove the meshes or the mesh IDs and provide me a reproduction I can test in my own place? It can better serve as a diagnosis. Because I am able to get this working with my own test model no issues.
I’m showing that by setting the CFrame how I currently am (CFrameValue.p) within the MoveTo method seems to mess it up, this works no matter which way I’m facing.
Utterly confused… when replacing the model with my own in your script it works perfectly lol…
Is there some difference when you use it in a server script? Afaik my code is identical to yours, but in a clientscript.
In the words of Khanovich, I am confused as to why you are trying to move a Humanoid on the client. This only works when you are near it and otherwise has null behavior or improper behavior because its NetworkOwnership phases in and out. Shown below.
Sorry, I can’t really give much help from speculation. If you could provide a reproduction place or model that would be optimal. Because something unseen is clearly affecting this given my example works.