Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I set the camera rotation to a horse HRP rotation (in cframe)?

Asked by 6 years ago

I don't know if the question is understandable but I want a horse to rotate in whatever way your looking. I made the animations and walking but I don't know how to make it so it sets the camera rotation to the hrp rotation, to make it even worse I don't think you can access the camera from a serverscript, any ideas or anyone who knows how to do it?

If you need the script I'm working with it's here

local Animations = script.Parent.Parent:WaitForChild('Animations')
local Horse = script.Parent.Parent

local Humanoid = Horse:WaitForChild('Humanoid')
local HRP = Horse:WaitForChild('HumanoidRootPart')

local WalkAnim = Animations:WaitForChild('WalkAnim')
local WalkTrack = Humanoid:LoadAnimation(WalkAnim)

local IdleAnim = Animations:WaitForChild('IdleAnim')
local IdleTrack = Humanoid:LoadAnimation(IdleAnim)

local Seat = Horse:WaitForChild('Saddle'):WaitForChild('Seat')
local WalkingSpeed = 0.5

local AVActions = {
    'Idle',
    'Walking',
    'Running'
}

local Animations = {
    'NA',
    WalkTrack,
    'NA'
}

CurrentAction = 'Idle'

function CFO()
    local O = Seat.Occupant

    if O then
        return true
    else
        return false
    end
end

function Move()
    if CurrentAction == 'Idle' then
        --
    elseif CurrentAction == 'Walking' then
        HRP.CFrame = HRP.CFrame + (HRP.CFrame.lookVector * WalkingSpeed)

    end
end

while wait() do
    local playerOn = CFO()
    if playerOn then
        local char = Seat.Occupant.Parent
        local plr = game.Players:GetPlayerFromCharacter(char)   

        if plr then
            CurrentAction = 'Walking'
        end
    else
        CurrentAction = 'Idle'
    end

    if CurrentAction == 'Idle' and IdleTrack.IsPlaying == false then
        print('Idle')
        WalkTrack:Stop()
        IdleTrack:Play()
    elseif CurrentAction == 'Walking' and WalkTrack.IsPlaying == false then
        print('Walking')
        IdleTrack:Stop()
        WalkTrack:Play()
    end

    Move()
end

0
Don't simply answer remote events, that could be possible but maybe crash the game as I would need a lot of camera changes.. User#20388 0 — 6y

Answer this question