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.

DarkBASIC Discussion / Advanced Camera Movement

Author
Message
Yodaman Jer
User Banned
Posted: 12th Oct 2009 18:17 Edited at: 12th Oct 2009 18:18
Hey everyone,

I'm trying to figure out a way to move the camera nicely, like you see in a cutscene in some games. I know the CurveValue command can be used somewhat, but I'd like to know of other techniques.

I don't need cutscenes right now, but I would like to practice a bit so that when I make my game I can implement them. Any tips and advice are appreciated!



"Having kids is hereditary. If your parents didn't have any, you won't have any either."
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th Oct 2009 21:16
For cutscenes I would almost think that using an outside animation program would be best then just use an avi. That way you can see it rather than guess and check as to how it will look.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Yodaman Jer
User Banned
Posted: 12th Oct 2009 21:20 Edited at: 12th Oct 2009 21:37
I thought about that, but my 3D animation skills absolutely suck.

Plus, I would rather program the cutscene so that the visuals aren't too different from the in-game models (because they will be the in-game models).

I've re-read my post and I realized I didn't give too much information. I was a little too vague. What I'm really looking for is ways to control the camera using something other than the simple CurveValue command. I'm going to try experimenting with something and I will post the results here, but I'm open to ideas anybody might have for controlling the camera.

Still too vague. What is it with me today?!

Could I use pathfinding routines or anything like that to control the camera?


Eh, on second thought I think I like the idea of using .AVI's. I don't really need to animate anything, just move the camera around the things that I need it to. I can still use the game models.



"Having kids is hereditary. If your parents didn't have any, you won't have any either."
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Oct 2009 22:19 Edited at: 13th Oct 2009 22:20
I must admit, I have NEVER seen ANYONE make a professionally controlled in-game camera on TGC. If you look at a game like Conker's bad Fur Day (Oh dear, here I go again with my old N64 games...), there is so much control and thought stuck into the camera, it will blow your mind just by thinking of it. It's as if the programmer has defined areas of camera states through the level, and if the camera enters this area, it does something. When walking up a spiral mountain, the camera automatically moves to the perpendicular of the mountain and points down at the player. When walking around in a narrow area, the camera will rotate around the bend you are going to make so you can see what's coming before you even turn. In a big stadium, the camera will always capture you and every enemy within a certain radius, smoothed and perfectly controlled.

It's unbelievable.

So, I suggest making areas like this. Just make a quick level editor and save the positions you define into a file to be read into your game. For example: Area 1 - Camera rotates 30° to the left of the player and points at any nearby objects. Area 2 - Camera locks into the corner and points at the player. And so on...

For checking where the camera is, use Pythagoras. But leave out the square root (It takes a long time). Instead of calculating the square root of the result, just multiply the value you want to check it with by itself:



As to cutscenes, you should use waypoints to control the camera. I do recommend AVI. Firstly, if not an AVI, it is possible that it will run slowly on other computers. Secondly, the music and sound will not be perfectly synced with the game unless using the Bass.DLL (a lost art). So, what you should do is program the cutscene, show it live (real objects) but no sound. Take every second frame so you have captured pictures that will make a video run at 30 fps, add them into a video editing program and add the sounds and music there.

TheComet


Make the paths of your enemies easier with WaypointPro!
Yodaman Jer
User Banned
Posted: 13th Oct 2009 22:36
Nice function there, Comet!

I like your idea about Conkers, however building a level editor is something that I'm not entirely sure how to make. Luckily I've found some resources. While they're for DBPro, I think they're adaptable to DBC.

Honestly though, before I get excited about any advanced camera movement, I've decided to start learning C#, so I'm going to halt programming in DB for just a while so that I can focus on C#. Even though I only just did the "Hello World" program, I really like the structure of C# and I'm definitely glad I chose to learn it.

After that, I'll see about building a level editor, hehe.

I like your idea about building an AVI as well, though I was thinking that I could just build my scenes in a 3D animation package and render it out from there. I'd use the game models so that there wouldn't be such a drastic difference between scenes and gameplay.

Thanks for your tip!



"Having kids is hereditary. If your parents didn't have any, you won't have any either."
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 14th Oct 2009 00:46
Comet man, the amount of times I've used pythagoras in my programs (one of the few things I know how to do so I overuse it a lot) and it never occurred to me to leave out the root. Well played, my man...

"A West Texas girl, just like me"
-Bush
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 14th Oct 2009 01:02 Edited at: 14th Oct 2009 01:20
For a while I've planned to make some functions for controlling the camera such as: circling a point, tracking (moving left,right,up,down), zoom, etc. but since I rarely use 3D I've not yet felt the urge.
I might give them a go actually, it would be good practice for getting into 3D.
This looks like quite a good page if you want to learn about camera angles and stuff link

TGC Forum - converting error messages into sarcasm since 2002.
Yodaman Jer
User Banned
Posted: 14th Oct 2009 01:03
Not only good practice for 3D, but also a useful thing for people to use.

Click the pic:
Yodaman Jer
User Banned
Posted: 1st Dec 2009 06:28
*EXTREME BUMP*

Haha, so I know it's been a while since I've asked a question in this board (so long that I got my name changed from Yodaman Jer to CoffeeCoder), but luckily this question is entirely related to the subject this topic was originally for. I love it when that happens.

Anyhoo, I want to try and make my camera scale in the screen, very similar to what one would see in Super Smash Bros. I'm currently coding in DBPro Free, but I trust you guys more than I trust the DBPro boards, hence why I'm asking here.

To elaborate, I need the camera to operate in such a way than when a player starts to go off screen, it zooms out and gives the players more room to jump around in and shoot each other. Does anybody have any ideas?

demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 1st Dec 2009 07:41
Thinking on my feet and not in code, but you could try:

If the player is more than (a little under half screen width) distance from the center of the screen horizontally or (a little under half screen height) distance from the center of the screen vertically:
1) Calculate how far off he is. Add a little extra space to this just so that his head isn't cut off or whatever.
2) Set a target camera zoom by either changing FOV or just moving the camera back on the z axis (assuming you're facing so that x is left/right, y is up/down).
3) Use curvevalue or any other method to gradually change from your current camera zoom to this one.

If the camera zoom is greater than default, but all characters are back within normal range,
1) Set target zoom back to default
2) Apply the same method as in the other section to return your camera zoom to normal


Sorry if it's useless I really need sleep but I'm overwhelmed with coursework. It's gone half 6 in the morning and I'm probably still 10 hours work away from a sleep. At which point I'll have a few hours nap, but then I have other stuff I need to do.

Hope this helps, but I'm quite aware that my half-asleep state may prohibit this. In fact, for all I can tell for sure, I may have just reinstated what you already knew, but this is the way I'd approach it. I wouldn't think that it would be too hard to use this approach for one player. The only thing which might be difficult is making sure it checked the right player/NPC so that it zoomed appropriate to the furthest from the center, not just the last listed in the loop or anything.

Yodaman Jer
User Banned
Posted: 1st Dec 2009 18:19
That's pretty much what I was thinking. I got some basic "scaling" done last night before bed:

[NOTE: I'm using Types, hence why variables have either a P1 or P2 as a preface]



I'm not entirely sure if this will go anywhere, but it's definitely a fun learning experience.

Does anybody know how I might make it zoom in/out more realistically? I'll see what I can do with the CurveValue command, but for some reason I feel that almost won't be enough...perhaps I like to over-complicate things. xD

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 1st Dec 2009 18:29 Edited at: 1st Dec 2009 18:34
I've been working on a camera tutorial for my web site, though it's not finished yet. But, to be honest, you can do far worse than using Set Camera To Follow. (There's a tutorial on that I've already finished).

For some form of intro, although I've never done it, I would be tempted to start with a hidden cube and attach the camera to it with Set Camera To Follow.

All you would need to do is move the hidden cube around where you want the camera to swoop (using waypoints for example) and tweak the settings as you go. Voila - and no maths involved.

I could knock an example together for you if you have any problems.

Hmmm... just noticed:

Quote: "[NOTE: I'm using Types, hence why variables have either a P1 or P2 as a preface]"


Are you by any chance using DBPro?

If so, methinks you could on the wrong board and are wasting our time...

TDK

Yodaman Jer
User Banned
Posted: 1st Dec 2009 18:56 Edited at: 1st Dec 2009 18:57
I am using DBPro now, but I asked this question in this old thread for two reasons: 1, this thread already existed and wasn't yet locked and I didn't want to create a new one, and 2, I know you guys better than I know people on the DBPro boards (and also, threads disappear and are forgotten very quickly on those boards!). I'll introduce myself on the DBPro boards soon, however.

I really like your idea TDK, I'm-a definitely gonna try it out! I'm thinking the following might work...



I don't have time to test it out. Would that work? I'll get to testing ASAP. Thanks!

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 1st Dec 2009 20:56
Quote: "For some form of intro, although I've never done it, I would be tempted to start with a hidden cube and attach the camera to it with Set Camera To Follow."

That's a pretty good idea TDK. Keeping it all in DBC without having to rack one's brain on the maths. Nice!

Quote: "2) Set a target camera zoom by either changing FOV or just moving the camera back on the z axis (assuming you're facing so that x is left/right, y is up/down)."

Makes sense Demon's Breath.

So I couldn't resist. I mainly typed this up for myself so I was sure I understood or at least think I understand the concept. Combining TDKs and Demons Breaths ideas, here's a Smash Bro's-esque camera. The cube in the center is TDK's focus cube. If the cones move out of screen then the camera pulls back. If they are all in screen, the camera moves forward. The cube is positioned based on the average of all the cone's positions so it's always in the center. The camera follows the cube. Change the set camera to follow settings to increase or decrease the lag.

I tried it using field of view as well, but the effect wasn't as good as just moving the camera physically closer or farther away.



Enjoy your day.
Yodaman Jer
User Banned
Posted: 1st Dec 2009 21:24
Wow Latch! That's great! Thanks!

Now I'll just study that and learn from it. I've found that when a person just copy>pastes others' code into the editor, they don't learn anything. And by "person", I mean me. Lol. At least I'm getting better!

Thanks all!

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 2nd Dec 2009 01:08
TDK's idea is brilliantly simple. If you wanted to do something different with the camera you can just move the focus object and use the same routine.

There are always interesting and varied ideas on this board

"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright

Login to post a reply

Server time is: 2024-04-19 11:37:11
Your offset time is: 2024-04-19 11:37:11