Camera Confusion??

Blitz3D Forums/Blitz3D Beginners Area/Camera Confusion??

W(Posted 2005) [#1]
I am having difficulties with the camera angles in my first person shooter game. The camera, which I have parented to a pivot(for the player), anyways the camera tilts in odd angles, and I can't seem to work the bugs out. Anybody have any suggestions?
-Oh I have the game set where the mouse allows the player to look around. And that's when the angles get all turned around.
Help.............


big10p(Posted 2005) [#2]
Try:

Have the mouse turn the camera directly, not the pivot it's attached to.

or:

If you turn your player pivot on the X or Z axis then the parented camera will turn with it, giving a weird angle view.

or:

Post some code. We're not psychic. ;)


Ross C(Posted 2005) [#3]
I bet your probably using turnentity. But, as Big10p says, post some code :o)


jfk EO-11110(Posted 2005) [#4]
I would also suggest: Move the pivot and turn it left and right to navigate the player, but turn the camera only up and down to look up and down. BTW this is exactly what I told you in the other thread.

something like

; let's assume there is a map mesh named "ground"
ENtityType ground,2

player=createpivot()
entityradius player,0.9 ; player is virtually 1.8 units tall for collision handling
entitytype player,1

camera=createcamera(player)
translateentity camera,0,0.9,0 ; eyeheight on 1.8 units

positionentity player,0,5,0

collisions 1,2,2,2

while keydown(1)=0
 if keydown(200) then moveentity player,0,0,1
 msx#=0.25*(-mousexspeed())
 msy#=0.25*mouseyspeed()
 movemouse graphicswidth()/2,graphicsheight()/2
 turnentity player,0,msx,0
 turnentity camera,msy,0,0
 translateentity player,0,-.5,0 ; simple gravity
 updateworld()
 renderworld()
 flip
wend



Zethrax(Posted 2005) [#5]
Basically you need two separate entities, one being your player entity (usually a pivot that you parent everything else to), the other being your camera. You'd normally parent the camera to the player pivot at about eye height.

The player pivot is the one you move to shift your characters position (normally using Moveentity so that your character moves in the horizontal direction that it is looking.

To do mouselooking, rotate the player pivot around its Y axis (yaw rotation), and rotate the camera pivot around its X axis (pitch rotation).

If you want to restrict the pitch rotation to within a certain range, you'll need to keep track of the pitch value in a variable, as the EntityPitch command is completely and utterly worthless due to the fact that it can return the same value for different angles.

The link below shows some mouselooking code in action.

http://www.blitzbasic.com/codearcs/codearcs.php?code=1137


W(Posted 2005) [#6]
Hey I fianally got it guys, it was one of those things that are soo simple that their difficult. Thanks for the ideas and suggestions Bill,jfk,RossC,big10p
-THANKS

-NOw to get to work on smooth jumping.....