meshY help FPS

Blitz3D Forums/Blitz3D Programming/meshY help FPS

anderstone(Posted 2004) [#1]
is there anyway to keep the camera a certain distance away from the mesh ground. i need it to stay the distance so it looks like you are looking through the eyes of the person. also the mesh is a .b3d mesh if that matters at all. i need the camera "person" to go up ramps and down stairs and vice versa.


big10p(Posted 2004) [#2]
I guess one way would be:
- create a pivot.
- give it an entity radius.
- set up a collision between it and the level mesh.
- parent the camera to the pivot.
- position the camera the required distance above the pivot.

You would then need to operate all your movements etc. on the pivot, not the camera itself.

OR: wait 'til someone with FPS experience comes along with a better solution! :P


anderstone(Posted 2004) [#3]
ok thanx that purty much solved that. thank you


anderstone(Posted 2004) [#4]
ok now how do i position the camera the distance from the pivot


Skitchy(Posted 2004) [#5]
Code may contain typing errors, but this method works 100% ;)

See my next post.


anderstone(Posted 2004) [#6]
ok thanx ill try that


anderstone(Posted 2004) [#7]
is there anyway to explain what the variables mean, because it is hard to know which variables match up to the ones i have


Skitchy(Posted 2004) [#8]
Sure. Happy to help. I also made a slight mistake in the LinePick() line but here's the updated version :

;'mesh' is your mesh landscape
mesh=loadmesh("mesh.b3d") 
;turn on polygon picking for the landscape
entitypickmode(mesh,2) 

repeat 
;...your code

;once you've updated your characters position, put this code in
;mycamera is your camera entity
;player_x is the x coordinate of the player. Use entityx() to get this
;player_z is the z coordinate of the player. Use entityz() to get this
;player_tall is the height you want to keep the camera above the ground

positionentity(mycamera,player_x#,meshy(player_x#,player_z#,30)+player_tall#,player_z#) 
;your code 
forever 

function meshy#(x#,z#,maxheight#,radius#=0.1) 
;this function returns the height (y) of a mesh landscape at the x,z coords given 
;maxheight is the height of the highest point of your landscape (just guess or use a large number)
linepick(x,maxheight,z,0,0-(maxheight*2),0,radius#) 
return pickedy() 
end function 



anderstone(Posted 2004) [#9]
hey thanks that worked out