This is the code i still cant figure it out? It's just the sponza tutorial with a sphere in it
Player = getObject("Player")
Head = getObject("Head")
room = getObject("room")
sphere = getObject("sphere")
dx = 0.0
dy = 0.0
centerCursor()
mx = getAxis("MOUSE_X")
my = getAxis("MOUSE_Y")
-- scene update
function onSceneUpdate()
    playerPosition = getPosition(Player)
    vec = normalize(sphereCenter - playerPosition)*0.98)
    -- rotate Player (X mouse)
    rotate(Player, {0, 0, -1}, dx*100)
    
    -- rotate Head (Y mouse)
    rotate(Head, {-1, 0, 0}, dy*100, "local")    
    rotation = getRotation(Head)
    if rotation[1] > 90 then
        rotation[1] = 90
    elseif rotation[1] < -90 then
        rotation[1] = -90
    end
    setRotation(Head, rotation)
    
    -- move    
    if isKeyPressed("W") then
        addCentralForce(Player, {0, 6, 0}, "local")
    end
    
    if isKeyPressed("S") then
        addCentralForce(Player, {0, -6, 0}, "local")
    end
    
    if isKeyPressed("A") then
        addCentralForce(Player, {-3, 0, 0}, "local")
    end
    if isKeyPressed("D") then
        addCentralForce(Player, {3, 0, 0}, "local")
    end    
    
    if isKeyPressed("SPACE") then
        addCentralForce(Player, {0, 0, 3}, "local")
    end    
    
    -- get mouse direction
    dx = getAxis("MOUSE_X") - mx
    dy = getAxis("MOUSE_Y") - my
    -- center cursor
    centerCursor()
    hideCursor()
    gravity = {0, 0, -90}
    
    mx = getAxis("MOUSE_X")
    my = getAxis("MOUSE_Y")    
    
end
(
Last edited by blend (2014-07-11 22:19:09)