Camera movement not in sync with player
Blitz3D Forums/Blitz3D Programming/Camera movement not in sync with player
| ||
Whenever I move around the camera moves at a different rate than the player. This causes the movement to get out of sync. I'm still pretty new at this so any help is much appreciated.While Not KeyDown(1) PositionEntity player, x#, y#, z# ;PositionEntity camera, x#, y#, z# x#=x#+xspeed# z#=z#+zspeed# ;y#=y#+.2 xspeed#=xspeed#*.90 zspeed#=zspeed#*.90 forward=KeyDown(17) back=KeyDown(31) moveleft=KeyDown(30) moveright=KeyDown(32) mouse1=MouseHit(1) mouse2=MouseHit(2) space=KeyDown(57) If forward Then zspeed#=zspeed#+.5 If back Then zspeed#=zspeed#-.5 If moveleft Then xspeed#=xspeed#-.5 If moveright Then xspeed#=xspeed#+.5 If space Then y#=y#+1 h# = h# + MouseXSpeed()/6.0 g# = g# + MouseYSpeed()/6.0 If g < -80 Then g = -80 If g > 80 Then g = 80 RotateEntity camera, g, 0, 0 RotateEntity player, 0, -h, 0 MoveMouse GraphicsWidth()/2, GraphicsHeight()/2 UpdateWorld() RenderWorld() Flip Wend End Yes, I know i still have to fix the y# movement, but i'd like to fix the camera thing first. |
| ||
Well before anyone looks at the code they will probably tell you to pivot the camera around the player instead of repositioning it manually. |
| ||
What do you mean? This is what I have: player = CreatePivot() camera = CreateCamera(player) |
| ||
This should work better, look into the UpdateGame() function: |