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 / [LOCKED] 3rd Person View Function (Quite Customizable and Functional)

Author
Message
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 28th Oct 2005 05:15 Edited at: 30th Oct 2005 12:52
Ultimate Camera Control Function
Created By RUCCUS


Use this function in your games for fast and easy camera control. It allows you to set a wide variety of variables to suit your needs. All you need to do is include the function in your program and call it once and it will handle everything else; just follow the simple instructions at the end of the post.

Great for any camera view you can think of, there's a sample at the bottom of this post containing 5 different views made using the function; 1st person view, 2nd person view, 3rd person view flying style, 3rd person view walking style, and 3rd person view map editor style w/ scroll button zooming.

There's a lot of parameters but after using it for a while you'll get used to it and adding it will become a cinch.

Features:

Easy implementation
Mouse/Camera rotation option
Mouse/Object rotation option
Camera rotation limits
Camera rotation speed
Customizable camera positioning and tilting
Easy zooming implementation

Syntax:

ThirdPersonView(Object, Dummy, Mesh, X, Y, Z, Tilt, Speed, DumX, DumY, ObjX, ObjY, MaxUp, MaxDown, MaxLeft, MaxRight)

Breakdown:

Object: The Object you wish to have 3rd Person View applied to.

Dummy: A "Dummy" object used for camera control. Specify this object number as an object not created in the game yet, the function will create the object using the dummy number.

Mesh: An uncreated mesh number that the function can use to add limbs with.

X: X offset for the camera; how far left or right of the user the camera will be.

Y: Y offset for the camera; how high or low the camera will be.

Z: Z offset for the camera; how close or far from the object the camera will be.

XTilt: The angle offset for the camera on the x axis, how far left or right of the object the camera should point.

YTilt: The angle offset for the camera on the y axis, how far above or below the object the camera should point.

ZTilt: The angle offset for the camera on the z axis, how far infront or behind the object the camera should point.

Speed: The speed at which the mouse rotates the camera and object. It's recommended setting this to a decimal (.1 works good). Setting this to 0 will cancel out the mouse rotation code, incase you don't want to use the mouse.

DumX: Set this parameter to 1 if you wish the mouse to rotate the camera around the x axis of the object.

DumY: Set this parameter to 1 if you wish the mouse to rotate the camera around the y axis of the object.

ObjX: Set this parameter to 1 if you wish the mouse to rotate the object around it's x axis as the mouse moves.

ObjY: Set this parameter to 1 if you wish the mouse to rotate the object around it's y axis as the mouse moves.

MaxUp: The Max upward rotation of the object/camera. Setting this to 0 will give no limits. Set this to a negative number.

MaxDown: The Max downward rotation of the object/camera. Setting this to 0 will give no limits. Set this to a positive number.

MaxRight: The Max rotation to the right the object/camera can go. Setting this to 0 will give no limits. Set this to a negative number.

MaxLeft: The Max rotation to the left the object/camera can go. Setting this to 0 will give no limits. Set this to a positive number.

Function Source Code:



Sample Code:

Here's some sample code on how to use the function. Alter it to experiment before implementing it into your game, press buttons 1 - 5 to switch between the views included in the program.



Add-Ons

Feel free to suggest any add-on features for the function. Critisism is encouraged, questions are welcomed. If the suggestion sounds good or the bug is legitimate I'll correct/add it as soon as possible.

Other than that, Enjoy

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 28th Oct 2005 21:51
I don't really need the third person view, but you just thought me how to rotate something round the z axis.. thanks !


RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 28th Oct 2005 22:13
Glad to hear it. It doesn't have to be for 3rd person view, come to think of it it can work for 1st 2nd and 3rd person views, it could also be applied to a map editor for rotating around your world. Starting to wish I didn't name the post 3rd person view...

If any mods out there can change the thread name to

"Fast and Easy Camera Manipulation (Great for 1st, 2nd and 3rd person view)"

I'd greatly appretiate it.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 29th Oct 2005 00:28
Updated

I changed the code around a bit to use 1 level arrays for the CamX and CamY variables, so you don't have to define them as globals anymore, the function will do it for you.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 29th Oct 2005 01:48
Updated

Changed the sample code largely, now it features 5 built in modes for you to experiment with. I also changed around some code in the actual function itself, it was showing problems with first person view but now it's fixed and working properly. I think it's pretty much done now.

Enjoy

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 29th Oct 2005 14:12
what's 2nd person view?


Wolf Dreamer
19
Years of Service
User Offline
Joined: 13th Sep 2005
Location: the land of chaotic dreams
Posted: 29th Oct 2005 21:20
Quote: "Zotoaste
what's 2nd person view?"


Where its like a second person is looking at you from behind. Also known as the butt cam.

--
Nice work RUCCUS!

Its good to see such a complete and well laid out and documented example. It makes mastering a new thing so much easier. Have you done any more examples like this for other things?

the last sane human being in a world gone mad
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 30th Oct 2005 01:45 Edited at: 30th Oct 2005 12:41
Quote: "Where its like a second person is looking at you from behind. Also known as the butt cam."


I always thought second person was an above view camera...

Quote: "Have you done any more examples like this for other things?"


I try to make demos and good layouts for all my snippets and functions, soon I'll be grouping together all the functions I've created and adding them to my site.

Thx for the feedback.

Deadwords
19
Years of Service
User Offline
Joined: 2nd Feb 2005
Location: Canada
Posted: 30th Oct 2005 02:06
Awsome code Ruccus, the 3RD Person / Walking was the exact view i was planning to code but, thanks, you made it for me
thanks.

PS: Is there any restriction about the use? (stupid question, eh )
(because my game is commercial)

=-{SKaleX}-= Current Projects: -Insane Killer-=-Chaos Zone-
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 30th Oct 2005 12:40
No else I wouldn't release the source. Royalty Free lol.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 30th Oct 2005 12:53
UPDATE

I thought I had everything working but apparently 2nd Person View had some of the settings wrong when I called the function so I just fixed them up, now it works.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 30th Oct 2005 19:54 Edited at: 30th Oct 2005 19:55
Would someone lock this thread I'm making a new one with a better suiting title.

Thanks,
RUC'

Login to post a reply

Server time is: 2024-11-23 11:33:08
Your offset time is: 2024-11-23 11:33:08