3rd Person Camera

  1. 5 months ago

    I'm new to Polycode and have been working with the example file "3DPhysics_Character." Currently I'm having trouble getting a working 3rd person camera. What I've done so far is added some code at the end of Main.lua through a fixedUpdate function that has been recommended in other posts about camera manipulation.

    function fixedUpdate(elapsed)
    scene:getDefaultCamera():setPosition(Vector3(player:getPosition()))
    scene:getDefaultCamera():lookAt(Vector3(0,0,0), Vector3(0,1,0))
    end

    Any help? Thanks!

  2. Hi Mage,

    You will want to position the player and camera in relation to one another first, then add the camera as a child entity to the character entity. It is deceptively simple. Once done, this will make the camera follow the transformations (translation, rotation) of the character. Your update code shown above should be unnecessary.

    camera:setPosition(0,1,3)
    camera:lookAt(Vector3(0,1,0),Vector3(0,1,0))
    cuteAnthropomorphicLeech:addChild(camera)

    Good luck.

 

or Sign Up to reply!