StarterCharacter points at the wrong direction when moving

Summary:
Hello developers! While creating a custom character I made, things were going great. I managed to rig and integrate custom animations onto this imported 3D StarterCharacter. Yet, once I got to test around, the movements were alright; but the animation or direction of the player was off. There are no similar DevForum posts or any YouTube videos I can find that showcased this problem.


Problem:
The StarterCharacter does not follow/face the correct direction when moving.


Observations:
D = moves right, points towards the camera
A = moves left, back towards camera
S = walks towards camera, points to the left
W = walks forward, points to the right


Video Showcase:


Suspected Issues:

  • The front of the character was made facing the -Y direction in Blender:

image

  • Animation might be facing the wrong direction: (Disproven)
    I tested it out and I disabled AutoRotate and it worked just fine, the character was moving forwards just as intended. The animations are playing as intended.

I have no idea what other possible suspected issues there are so I would tackle them, but the rotation of the character seems inversed or switched up, despite correct movements.


Attempted Solution:

Disabling AutoRotate and creating custom directions to where the character points:

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Camera = game.Workspace.CurrentCamera

-- Disable AutoRotate
Humanoid.AutoRotate = false

local function updateCharacterRotation()
    local cameraCFrame = Camera.CFrame
    local cameraLookVector = cameraCFrame.LookVector
    local cameraRightVector = cameraCFrame.RightVector

    local moveDirection = Vector3.zero

    if UserInputService:IsKeyDown(Enum.KeyCode.W) then
        moveDirection = moveDirection + Vector3.new(-1, 0, 0)
    end
    if UserInputService:IsKeyDown(Enum.KeyCode.S) then
        moveDirection = moveDirection + Vector3.new(1, 0, 0)
    end
    if UserInputService:IsKeyDown(Enum.KeyCode.A) then
        moveDirection = moveDirection + Vector3.new(0, 0, -1)
    end
    if UserInputService:IsKeyDown(Enum.KeyCode.D) then
        moveDirection = moveDirection + Vector3.new(0, 0, 1)
    end

    if moveDirection.Magnitude > 0 then
        moveDirection = moveDirection.Unit

        local relativeMoveDirection = moveDirection.Z * cameraLookVector + moveDirection.X * cameraRightVector

        -- Ensure the character rotates to face the direction of movement
        local newLookAt = HumanoidRootPart.Position + relativeMoveDirection
        HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.Position, newLookAt)
    end
end

-- Connect the update function to RenderStepped for smooth updates
game:GetService("RunService").RenderStepped:Connect(updateCharacterRotation)

UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    updateCharacterRotation()
end)

UserInputService.InputEnded:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    updateCharacterRotation()
end)

Issues with the proposed solution:

  • Does not work with mobile users, as they do not have KeyDown
  • The problem is probably easier to fix, as it might be an issue with the model or something with the Humanoid or HumanoidRootPart
  • When two buttons (ex. W + A) are clicked, the character tilts backwards and there is no smooth transition.

Additional Information:

The charcter was auto-rigged in Mixamo, and the animations were taken from there.

This YouTube video was followed in order to learn how to create a custom StarterCharacter:
CSM- How to Use a Custom Rig & Character in Roblox Studio - YouTube

Hierarchy of StarterCharacter
image

Properties of Humanoid (R15)

The HumanoidRootPart: (Everything was turned off in the Collisions except the HumanoidRootPart)

The classic Roblox Animate script was used, and the animations were substituted in.


Let me know if there are any additional information I should post here, and do let me know if there are any problems with anything I have mentioned and if there are any possible fixes to this issue. Thank you so much for reading this. :happy1:

1 Like

Alright, I solved it. It was quite easy to fix. The issue was the HumanoidRootPart was facing the wrong part. I knew this issue was easy to fix.

Note to any future developers: if you’re mesh is facing the wrong direction check this post out:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.