Page 1 of 1

Help rotating the camera with my player

Posted: Tue Dec 02, 2014 12:04 pm
by n1c
Hey guys!

I've looked around (viewtopic.php?f=4&t=78216, https://github.com/kikito/gamera) but really can't figure out just where I'm going wrong when trying to rotate the camera so my player always faces "up" in my little game.

The code can be found here - https://github.com/n1c/dash as far as I can tell I should be setting the rotation here https://github.com/n1c/dash/blob/master/game.lua#L41 based on the player's angle in the world. Though that seems wrong in practice.

Any insight would be greatly appreciated! Gamedev is new to me and it's been quite a while since doing trig so I feel so in the dark! :awesome:

Re: Help rotating the camera with my player

Posted: Wed Dec 03, 2014 11:03 am
by kikito
Hi there,

You are not using gamera, but BlackBulletIV's camera

I might be wrong, but probably your control scheme (which makes the player "look at" the mouse) is not compatible with "rotating the camera to where the player is looking at". This is because BlackBulletIV's code does not take into account the camera's rotation when returning the mouse coordinates.

gamera does take this into account, so it might help you with that (hump's camera also does it). However your control scheme will still not be compatible with it - you will need to "gradually adjust the roation of the camera so that it matches the player angle", not "set it to the player angle". Otherwise it will be too abrupt.

Re: Help rotating the camera with my player

Posted: Wed Dec 03, 2014 2:21 pm
by n1c
Yeah the linked code uses BlackBulletIV's lib, I should have explained a bit that I'd also tried out gamera but hadn't made any useful progress.

Thanks for the reply. I'll look in to the control scheme you mention!