Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Prevent camera looking up and down

Author
Message
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 13th Jul 2008 00:38
Hi, I am sure this is very simple to do, but how do I prevent the camera from looking more than 90 degrees up and down? So that I can't rotate the players head upside down.

The game is in First Person if you need that kind of info.

And my camera code looks like this:



- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 13th Jul 2008 01:20
What you want to do is lock the ability to look on the x axis if the angle of axis goes past the limited angles. In this case, the uplook max angle could be something like -85, and the down 60. This gives a fairly good degree of freedom for look on the x axis.

EX:


I hope that helps.
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 13th Jul 2008 01:37
It did work, but... How do I remove these annoying flickering when the camera is changing position?

When I look down for example, and reach the limit, the screen starts flickering because the camera is constantly changing position.

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Moe
18
Years of Service
User Offline
Joined: 1st Apr 2006
Location: Sunny California
Posted: 13th Jul 2008 01:42
You could say that the camera only goes through the command that rotates the camera if the x angle is less than 59, and more than -84

parrot
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 13th Jul 2008 01:51
I modified these commands so that it checks if the the x angle is less or equal to 60, and more or equal to -80, still same problem. Any suggestions?

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Moe
18
Years of Service
User Offline
Joined: 1st Apr 2006
Location: Sunny California
Posted: 13th Jul 2008 02:43 Edited at: 13th Jul 2008 02:43
that kinda takes away the point, because it's always going to be less than or equal to that. Try less than 60, or more than -80.

parrot
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 13th Jul 2008 03:08
That makes me unable to move the camera in thoes directions.

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 13th Jul 2008 11:08
Try this.




oh my god
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 14th Jul 2008 09:25 Edited at: 14th Jul 2008 09:27
The code below works perfectly. No jittering and the lock works like a charm:



As I have, make sure that you use a mousemove command only once per loop. Record its value in a variable at the start of your main loop. Otherwise you'll run into some weird bugs, due to the way the command stores data per each call.
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 14th Jul 2008 22:09
Thanks, that works perfectly, I will remember that.

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/

Login to post a reply

Server time is: 2024-11-25 01:49:43
Your offset time is: 2024-11-25 01:49:43