Make the camera ignore the character

Status
Not open for further replies.

amperbee

thunderdome denizen
Retired Staff
Exactly what the long title says.

I'm making the camera shake to simulate a quake of sorts, but it is only "effective" when the player is not in first person.
When the player enables first person, the camera occasionally hops behind the player and the view gets blocked by the player's character for a single frame. As it (the camera) randomly moves, the character flashes on the screen, and it might get a bit annoying over time.

So the question is, is there any way the character is fully invisible to the client only when the camera jumps behind it?
Or at least is there a way to make the camera stop making the character pop up on the screen?
 
Problem is, all the first person mode does is putting the camera inside the player to simulate first person view, it doesn't remove it. This said, even the game's earthquake effect will make the 1st person camera shake in a way that the player might appear on the view. Setting the player to an invisible state would also affect everyone, giving a somewhat unfair advantage to said player.

Tl;dr: No.
 
<snip> even the game's earthquake effect will make the 1st person camera shake in a way that the player might appear on the view. Setting the player to an invisible state would also affect everyone, giving a somewhat unfair advantage to said player.

Well, that's bad. I never knew the camera was only moved instead of something else.
And the camera is read only, so there is no way to make it just not go backwards.

Oh, and thanks for your answer!
 
Try this

Code:
local invisiblePlayer, oldInvisiblePlayer

-- Figure out if someone needs to be made invisible
hud.add(function(v, player, camera)
    if camera.chase or player.awayviewtics then -- Camera is NOT first-person, so make nobody invisible!
        invisiblePlayer = nil
    else -- Camera IS first-person, so make the current-viewed player invisible!
        invisiblePlayer = player.mo
    end
end, "game")

-- Now to actually make the player invisible!
addHook("ThinkFrame", do
    -- Make old invisible player visible again if we've changed
    if invisiblePlayer ~= oldInvisiblePlayer then
        -- Validity checks to avoid errors
        if oldInvisiblePlayer and oldInvisiblePlayer.valid then
            oldInvisiblePlayer.flags2 = $1 & ~MF2_DONTDRAW
        end
        
        oldInvisiblePlayer = invisiblePlayer
    end
    
    -- Make new invisible player constantly invisible
    if invisiblePlayer and invisiblePlayer.valid then
        invisiblePlayer.flags2 = $1 | MF2_DONTDRAW
    end
end)
-- WARNING: from this point on, DON'T make any Lua scripts change behavior, except for some visual effects, based on whether a player is invisible. Doing so WILL cause desyncs.
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top