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.

Code Snippets / [DBC] 3rd person 1st person toggle with look around

Author
Message
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 16th Nov 2009 04:05 Edited at: 22nd Nov 2009 17:51
I was going through some code in one of my folders and found an example I typed up earlier this year in answer to a question. I thought I'd post it here. It's a way of toggling between 3rd person and 1st person perspective. In 1st person mode, you can also look around or aim with just the 'head' of the character.

The character, in this case, is a small green cube stacked on a white cube. The green cube is the head.

Press the [SPACE] key to toggle between perspectives. While in 1st person, hold the RIGHT mouse button and a circle target reticle will appear on the screen. Move the mouse around and the green head will move and you can aim. The body will stay still.

In both modes, move with the arrow keys and steer with the mouse. You can move around freely in either mode but while holding the Right Mouse button and aiming, you cannot move.



Enjoy your day.
seppgirty
FPSC Developer
14
Years of Service
User Offline
Joined: 3rd Jul 2009
Location: pittsburgh, pa.
Posted: 22nd Nov 2009 01:52
thanks for the code... could defantly use it

gamer, lover, filmmaker
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 22nd Nov 2009 17:52
You're welcome.

Enjoy your day.
farmkid4
14
Years of Service
User Offline
Joined: 23rd Sep 2009
Location: on my pc :)
Posted: 12th Dec 2009 00:55
nice code thanks for posting

When in doubt use the search bar.
B++
14
Years of Service
User Offline
Joined: 6th Dec 2009
Location: India
Posted: 13th Dec 2009 01:27
Thanks a lot for postion the code. Now I know how to make a key toggleable

Your Signature Here;
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 14th Dec 2009 01:28
You're welcome! I noticed I did a little flipflop in the toggle code:

if os > ns

While this works, the mode switch will wait one iteration to go into effect. The values should be switched:

if ns > os

Enjoy your day.
B++
14
Years of Service
User Offline
Joined: 6th Dec 2009
Location: India
Posted: 14th Dec 2009 19:47
Thanks

Your Signature Here;
Kolotation
14
Years of Service
User Offline
Joined: 31st Dec 2009
Location:
Posted: 1st Jan 2010 07:58
Hmm, this is a good looking code to study.

I'm trying to better understand this kind of thing.

Thanks a million!

Awesomeness comes easy.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Jan 2010 04:47
Feel free to ask if you don't understand any parts of the code.

Enjoy your day.

Login to post a reply

Server time is: 2024-03-29 15:47:51
Your offset time is: 2024-03-29 15:47:51