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.

Dark GDK / Any advise on camera?

Author
Message
CallumD
13
Years of Service
User Offline
Joined: 30th Mar 2011
Location: United Kingdom
Posted: 1st Apr 2011 22:11
I've just recently gone from 2D programming to 3D. I've gotta say, 3D maths is very hard :/

I'm having trouble with setting up the camera. I have a player model, and I want the camera to remain behind him slightly, and look forwards (based on the GTA III camera system). If any of you have played it, you will know moving the mouse left/right, turns the camera, and also the camera, and moving the mose up/down just aims up/down.

Does anybody have a simple formula of how to work this?
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 2nd Apr 2011 02:05
If you are following an object around then you can simply place the camera at the objects coords and then set the camera rotation to the same as the objects. To view the object from behind it then just move the camera backwards.



dbMouseMoveX() and dbMouseMoveY() are the commands you would probably be looking for to control the movement of the objects.

Warning! May contain Nuts!
Dodga
14
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 2nd Apr 2011 02:41
If you want to move up and down with the camera, it'll be more complicated, do you have the ezrotate plugin?
CallumD
13
Years of Service
User Offline
Joined: 30th Mar 2011
Location: United Kingdom
Posted: 2nd Apr 2011 23:24
Thanks for the help, WLGfx, that helped a lot, but there are still some minor problems;

1. object X,Y,Z returns the bottom of the model, that's correct? I just use Y+60 or something?

2. If I rotate the camera the same as the player, I see his front, and not his back. Has the model been done incorrectly? I got it from the Game Creator Store, so I wouldn't have thought so.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 3rd Apr 2011 00:13 Edited at: 3rd Apr 2011 00:15
Try this:

You will have to declare globals:
float AngleY,AngleX,Distance;

If you want to only move the camera when you do a key press like rightclick(), then you will have to do something like this:

The part with dbPositionCamera(0,0,0); is where you would set it to your "player object".

The fastest code is the code never written.
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 3rd Apr 2011 01:22
You can use this command, I used to find it worked pretty well.


WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 3rd Apr 2011 02:00
All depending on where the object is positioned in local space. (ie a man will have his feet on the ground usually centered at xyz 0,0,0) His head will be higher (at y, the height of the man object). Rotating the player on the Y axis will turn him around left or right. This is also the same for the camera if positioned near and orientated to the player.

You will find that using the free flight functions will mess up certain other function. (free flight are roll, pitch and turn). So to turn your player around left or right safely just use:

dbYRotateObject(objectnum, new_angle)

however you will need to increment the original value using

dbYRotateObject(objnum, dbObjectAngleY(objnum) + new_angle)

Moving the player around (I am getting to something here). You can reposition you player using dbSin and dbCos. (similar to what you do in 2d coords)

Using this kind of movement system allows you to use the 'SetCameraToFollow' because the free flight commands mess it up.

Moving on again... Although your player may only move across the X and the Z axis (the ground plane because Y makes things higher). This is were sliding collision comes in using something like Sparky's.

Warning! May contain Nuts!

Login to post a reply

Server time is: 2024-11-19 12:38:11
Your offset time is: 2024-11-19 12:38:11