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 / Hello, I'm new! Camera Question =]

Author
Message
Kool Dude
15
Years of Service
User Offline
Joined: 18th Nov 2009
Location:
Posted: 18th Nov 2009 16:34
Hey everyone, I'm new! And since TGC released a free version of DBP I decided to go ahead and get it... what could I lose?

Well, so I've been messing around with it and I've managed to come up with something very small. I have no programming experience what-so-ever... I'm trying to move away from the almighty RPG Maker 'cause I've been using that since I was a kid! And now I think it's about that time... So here I am!

I've been meaning to start digging into some tutorials especially with that thread with all the links...

but anyways...

I have a question. Okay so, I have a basic movement set up and a camera positioned to look down at the cube at a 45 degree angle...

I'm curious, how can I make the camera follow the cube? I don't want the camera to move forwards or backwards with it, just rotate to the left and the right as the cube gets closer to the edge of the screen and tilt it up when the cube gets far out, and tilts down as the cube gets closer...

Know what I'm saying?

Also, how can you have two cameras? For example, if the player was to go so far out, your view would have to change to another camera so that the player could be seen again... Like in Final Fantasy or Resident Evil.

I hope I'm not asking a lot, I'm just really curious and kind of excited that I actually managed to get this far with DarkBasic!

And if you're gonna' be an awesome person and tell me how to do it, it would be great if you could go into detail and explain why it does what it does... 'Cause I'm new!

Here's my code...



If there is a better way or an easier way to accomplish this then please tell me...

But again, like I said... it's very basic, but I couldn't be any more proud.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Nov 2009 18:10 Edited at: 18th Nov 2009 18:19
well, that's a good start. here's some advice on it and what you want to do:

1) make sure you add autocam off before your other camera commands to tell the app you'll be handling the camera stuff yourself.

2) look at the point camera help file again and know that this line in your code:

is pointing at those coordinates in 3d space and is not rotating the camera, per se, as i think you're expecting. you shouldn't need any of the camera rotation commands to do what you want here (see next item).

3) point camera is also the command you need to follow the cube the way you want. as the object moves, point camera at the cube's current coordinates (this must be called whenever the cube moves so include it in your loop).

4) you don't need a second camera to "catch up" to the cube when it gets too far away; just get the x and z coordinates of your cube and compare them to your camera's x and z coordinates. if one of them differs by more than, say, 500 units (you decide), you would re-position the camera closer to the cube, thus "catching up" to it. decide on a base z & y offset for your camera and, when the object gets too far away, re-position the camera to your cube's current position and apply the offsets mentioned (ie, add or subtract the offsets), and don't forget to call the point camera command again.

for all of this, look into these 3d commands/expressions:


and these camera commands:


good luck!


zeroSlave
15
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 18th Nov 2009 18:13 Edited at: 18th Nov 2009 18:15
The easiest way would be to put Point Camera Object Position X(1),Object Position Y(1),Object Position Z(1) inside the loop. Like thus:


This tells the camera to look at where the object is located each time the screen is updated.

As far as making two cameras and having them function the way you would like, I would imagine it would take quite a bit more work. I am not super fluent in the use of multiple cameras, hopefully someone else can help you with this!

Edit: Virtual Nomad made a much nicer post!

There's something in this room that makes you can't speak well.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Nov 2009 18:18
@coughmist, i wish there was an alert here that states "another user is currently responding to this post". would save us all so much grief


Kool Dude
15
Years of Service
User Offline
Joined: 18th Nov 2009
Location:
Posted: 18th Nov 2009 18:40
Oh! okay, it's starting to make sence... so, what if the player moves off of the camera, then it catches back up to the player. How would I go about changing the camera angle? For example... The camera would start at that 45 degree angle, then once the player is out of sight, the camera catches back up, then it changes to a sideview shot...

I had always figured there would just be multiple cameras set up and whenever the player was within a certain range of one of those cameras it would trigger it on and switch to that camera, and even at times the camera would follow the player until the player was within the range of another camera, but what do I know? I'm just a noob!

And also,for some reason I can't go and reference the list of commands in the help file anymore...

Everytime I try and open the help, a new tab opens up... But... it's completely blank. There is nothing there, it was working just fine a little bit ago, but I don't know what happened?

Maybe I should re-install it?
zeroSlave
15
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 18th Nov 2009 19:01 Edited at: 18th Nov 2009 19:01
Or even a notification when a post has been made while a user is typing!

There's something in this room that makes you can't speak well.
Kool Dude
15
Years of Service
User Offline
Joined: 18th Nov 2009
Location:
Posted: 18th Nov 2009 19:41
Thanks Coughmist for that little line of code!
But now I'm confused...

So I added that code you gave me, then I ran it... and It changed my movement, maybe? When I compiled and ran it instead of moving forward, backwards, left and right, it looks like when I go forward it begins to move downward and when I move back it comes up and as for the left and right it, it rotates the cube.

Then again maybe it is doing what it's supposed to do and since it's a box I just can't really tell what's going on!

I guess it's time I try and import a level and a character now and see where that takes me!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Nov 2009 01:12
Take a look at number 18 here:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

It would also be of more use to turn the object left and right with LeftKey() and RightKey(), making use of WrapValue(). All the commands are in the help files (just press F1 for them).

A minor point: get into the habit of indenting your code now - before it's too late!

The link above has many tutorials which teach you the basic building blocks of programming. Without a good understanding of the fundamentals, any programs you write bigger than what you've done already are doomed to failure...

TDK

TDK

Kool Dude
15
Years of Service
User Offline
Joined: 18th Nov 2009
Location:
Posted: 19th Nov 2009 06:14
Thanks! I'm gonna start digging into those tutorials!
TDK, your tutorials look like they will be very helpful for me just starting out! And the user who does the DarkPrinciple vids is definatly something I'm gonna look into!

I just wish I knew what all the topics were that he covered... not that it would matter, because it's not like I would have known how to do it anyways. I'm just curious!

But yeah, I don't know what happened to my helpfile. Every time I try to open it, a new tab opens for the help, but it's blank! It wasn't like that earlier today... There's nothing there so I have to go through my program files and all that to open up the help... *sigh* it's rather annoying! BUT! Oh well, I can live with it!

Is there possibly a way to fix this?

Login to post a reply

Server time is: 2024-11-23 22:23:12
Your offset time is: 2024-11-23 22:23:12