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 / Problems with camera following an object

Author
Message
iamliam
18
Years of Service
User Offline
Joined: 13th Nov 2005
Location: Toronto, ON, Canada
Posted: 13th Nov 2005 19:20
Hi everyone,

I'm new to DarkBASIC Pro and this community, but I am excited to become an active member here

I used some bits from various other code snippets, the most prominent one being that the chase cam function was from Binary Moon's dbc tutorial, with a little bit of modification.

Everything looks fine when you start it up, and when you go forward/backward/up/down etc., but when you start to turn, once you turn at a certain angle, the object just goes free of the lock in front of the camera, until you turn about 180 degrees again, then it locks back in.

Does anyone know what's going on?

Thanks,

Liam
iamliam
18
Years of Service
User Offline
Joined: 13th Nov 2005
Location: Toronto, ON, Canada
Posted: 13th Nov 2005 23:02
Crap, I suppose there is a problem with the "Source" button there. Sorry about the double post...

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 14th Nov 2005 00:53
Take a look in the Code Snippets forum, search for view and click the Thread titled "Camera Control Function | ...". It's a function I made for easy camera manipulation, I'm altering it a lot more tonight to suit even more possibilities for as is now it should work perfectly for 3rd person view.

iamliam
18
Years of Service
User Offline
Joined: 13th Nov 2005
Location: Toronto, ON, Canada
Posted: 14th Nov 2005 01:29
Thanks for your reply, I checked out your code, and I had a hard time following it

I simply want the camera to remain behind the cube at all times, maybe you could give me a line of code to use with your function to do this? I don't need mouse rotations or anything.

Thanks
Lame Brain
19
Years of Service
User Offline
Joined: 28th Apr 2005
Location: Portland, OR
Posted: 14th Nov 2005 17:14
a simple, if inelegant way to do this is to simply do the folling:

1. place the camera at the same position as the object it is supposed to follow.

2. make the angle the same as the object it is supposed to follow.

3. move camera -10 (or however far back you want it to be)

4. refresh the screen.

This is a work-around. If you use more complex code to figure out where the camera should actually be, you can have your camera that chases that point, and creates a feel of real motion. This method will allow the camera to be behind your object, but feels rigid. Also this method is not efficent, and in complex enviroments, you may lose frame rate. The plus side, however, it is simple!

Another hair-brained idear from... LAME BRAIN!
iamliam
18
Years of Service
User Offline
Joined: 13th Nov 2005
Location: Toronto, ON, Canada
Posted: 14th Nov 2005 18:36
Oh, thanks, that'll be suitable for now
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 15th Nov 2005 01:59
There is a sample of using the function on that thread, just paste the sample code into DBP, the numbers cycle through the modes, the first mode is exactly what you want, if you dont want the mouse moving the camera set the speed to 0.

Im working on making the function simpler now.

Login to post a reply

Server time is: 2024-09-24 09:32:48
Your offset time is: 2024-09-24 09:32:48