Quote: "What kind of angle? like a little bit above the player pointing down?"
We can only guess...
Ordinary 3rd camera following
sync on : sync rate 100
`Create matrix
make matrix 1, 1000, 1000, 50, 50
randomize matrix 1, 5
`Create player
make object cube 1, 3
do
`Move player
if upkey() = 1 then move object 1, 0.3
if downkey() = 1 then move object 1, -0.3
if leftkey() = 1 then yrotate object 1, wrapvalue(object angle y(1) - 3)
if rightkey() = 1 then yrotate object 1, wrapvalue(object angle y(1) + 3)
`Position on matrix
y# = get ground height(1, object position x(1), object position z(1)) + 1.5
position object 1, object position x(1), y#, object position z(1)
`Do the camera things
ChaseCam(1, 10.0, 5.0)
sync
loop
`The function
function ChaseCam(id, distance#, height#)
`Extract data
posx# = object position x(id)
posy# = object position y(id)
posz# = object position z(id)
angy# = wrapvalue(object angle y(id) - 180)
`Calculate camera position
camx# = newxvalue(posx#, angy#, distance#)
camy# = posy# + height#
camz# = newzvalue(posz#, angy#, distance#)
`Smooth camera
camx# = curvevalue(camx#, camera position x(), 15)
camy# = curvevalue(camy#, camera position y(), 15)
camz# = curvevalue(camz#, camera position z(), 15)
`Update camera
position camera camx#, camy#, camz#
point camera posx#, posy# + (height#/2), posz#
endfunction
Or using your mouse to rotate around your player:
sync on : sync rate 100
`Create matrix
make matrix 1, 1000, 1000, 50, 50
randomize matrix 1, 5
`Create player
make object cube 1, 3
do
`Move player
if upkey() = 1 then move object 1, 0.3
if downkey() = 1 then move object 1, -0.3
if leftkey() = 1 then yrotate object 1, wrapvalue(object angle y(1) - 3)
if rightkey() = 1 then yrotate object 1, wrapvalue(object angle y(1) + 3)
`Position on matrix
y# = get ground height(1, object position x(1), object position z(1)) + 1.5
position object 1, object position x(1), y#, object position z(1)
`Do the camera things
cangx# = wrapvalue(cangx# + mousemovey())
cangy# = wrapvalue(cangy# + mousemovex())
ChaseCam(1, 10.0, cangx#, cangy#)
sync
loop
`The function
function ChaseCam(id, distance#, angx#, angy#)
`Extract data
posx# = object position x(id)
posy# = object position y(id)
posz# = object position z(id)
`Calculate camera position
camy# = posy# + (sin(angx#) * distance#)
camx# = newxvalue(posx#, angy#, cos(angx#)*distance#)
camz# = newzvalue(posz#, angy#, cos(angx#)*distance#)
`Smooth camera
camx# = curvevalue(camx#, camera position x(), 15)
camy# = curvevalue(camy#, camera position y(), 15)
camz# = curvevalue(camz#, camera position z(), 15)
`Update camera
position camera camx#, camy#, camz#
point camera posx#, posy# + (height#/2), posz#
endfunction
Try to understand the code, so you can adapt it in your own games. If there is anything you don't understand about the code, please post it here.
It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.