As I’m sure you’re already aware. Simply calling Humanoid:MoveTo() or Humanoid:Move() will automatically cause an NPC to face the direction specified as they move.
How would I be able to make an NPC strafe to a given location? By this I mean move toward where I told it to, but constantly be facing a different direction? I understand the AutoRotate feature can be turned off, but in a situation of target tracking, how would I change which direction the NPC is facing, while it’s moving?
Changing its CFrame while it moves I guess?
I considered that, but changing it’s CFrame would interrupt the movement, it’d either kill the NPC, abandon the moveto() or just look choppy.
August 28, 2019, 5:37pm
Change the CFrame of the motor6D Joints.
Create a walk animation and sync it with moving the CFrame instead of using :MoveTo()?
Wouldn’t that change only the rotation of the welded parts, not the humanoidrootpart?
I’ve seen people using BodyGyros for this, so I’m looking into that instead.
August 28, 2019, 5:40pm
You should make the HRP invisible and the other parts should be welded. I’m not sure if the HRP is welded too.
The HumanoidRootPart doesn’t contain any welds, all welds are “rooted” if you will, to the HRP. So changing the welds doesn’t affect the HRP at all.
August 28, 2019, 5:41pm
Well it should be invisible, so it shouldn’t matter too much to the user.
I’m designing a full on AI bot system. So the HRP’s rotation substitutes as camera vectors for the AI.
August 28, 2019, 5:42pm
The easy way would be to use
BodyGyro to keep the NPC facing the correct direction while not interrupting its intended path.
Make sure to have it’s
MaxTorque property a little like this: Vector3.new(0,40000,0) where only the Y value has anything greater than 0.
Then, via scripting, change it’s CFrame property (generally hidden) to the angle you desire. Since the other 2 in
MaxTorque are at 0, only its left-to-right rotation (the Y-axis) will be affected.
Thanks, that actually helps a lot. I was going to do some scripting solutions to remove X and Z rotation from the system, but that’s a much easier solution.