"Exciting" Cameras

Blitz3D Forums/Blitz3D Programming/"Exciting" Cameras

Picklesworth(Posted 2005) [#1]
Since cameras seem to be the theme right now, I may as well post this question that's been bothering me for some time.
I have always found that with practically any game I start on, the thing that really holds me back is the camera. Basically, my problem is that it doesn't move in any kind of an exciting way. With most games, the camera will bob about in places, and when whatever it is following stops moving, it will take a small bit of time to stop itself, maybe having some kind of extra bobbing about added there. My question is, how is this sort of thing done? What kinds of ideas should I go by to have a camera that moves around in that kind of an exciting and floppy manner?

(Note, doing this for a 3dish sidescrolling game)


Chimeara(Posted 2005) [#2]
try something like this (you'l have to creat a 'speed')and replace the "your name here" with your main .

PointEntity(camera,gtar1)

If EntityDistance(camera,"your name here") > 700 MoveEntity(camera,0,0,speed * -1)
If EntityDistance(camera,"your name here") < 0 MoveEntity(camera,0,0,speed )

If EntityY(camera) < 250 PositionEntity(camera,EntityX(camera),250,EntityZ(camera))

EndIf


Chimeara(Posted 2005) [#3]
and the scale might be out, i was using this for a big object.


Picklesworth(Posted 2005) [#4]
Cool :D Thanks. It's nice and simple, as I'd hoped.
Pretty bad I couldn't figure that out myself!

Just to make myself useful: I'm going to throw in another variable that's multiplied by as well, which is the distance between Camera and Object. That could be used to get a less constant speed, which is always cool. Most of the calculations will be done with ints and not so precise numbers for speed stuff, to allow for some purposeful imperfection (this way, the 3dishness is more 3dish because the camera would rotate a little to see the character perfectly, giving a hopefully very subtle effect).


WolRon(Posted 2005) [#5]
How can EntityDistance be *less than* zero?


Picklesworth(Posted 2005) [#6]
I wrote a quick equation that does that for my movement pegs code. Only 2d, but probably easily done in 3d - though I'm not planning to do it for 3d myself (I'll simply switch the X and Y axis's to Y and Z or whatever) so you'll have to do that yourself. The idea is pretty simple though, so it shouldn't be too hard to get.

edit: Um yep... Come to think of it, it's completely improper for diagonals, and should not have been named Distance2. I'll just leave it here though for the heck of it. You could use a normal distance function multiplied by the result of Distance2 divided by Abs(itself)
Or maybe I'm just asleep right now and it does work :D


Function Distance2#(x1#,y1#,x2#,y2#)
	;Returns negative or positive numbers
	X# = x1-x2
	Y# = y1-y2
	Return X+Y
End Function



Edit again:
This works. It's backwards because I'm working very very quickly, but it works. I think.
Graphics 800,600,0,2
SetBuffer BackBuffer()

While Not KeyDown(1)

	Plot 400,300
	Line 400,300,MouseX(),MouseY()
	
	PosORNeg = distance2(400,300,MouseX(),MouseY())/Abs(distance2(400,300,MouseX(),MouseY()))
	
	result = Distance(400,300,MouseX(),MouseY()) * PosORNeg
	
	Text 10,10,"Length " + result
	
	Flip
	Cls
Wend
End


Function Distance2#(x1#,y1#,x2#,y2#)
	;Returns negative or positive numbers
	X# = x1-x2
	Y# = y1-y2
	Return X+Y
End Function

Distance is in the Blitz3d userlib.


big10p(Posted 2005) [#7]
I reckon the most 'exciting' cameras are ones that are detached in some way from the object they're tracking - instead of being rigidly fixed, pointing directly at the subject.

For example, of the myriad racing games about, most seem to use a fixed/focused chase-cam that doesn't convey any sense of speed/acceleration/deceleration. If I were to do a racing game, I'd:
- Give the camera some degree of judder, maybe related to bumps in the road surface.
- Pull the camera away from the car in relation to acceleration, and then gradually pull it back in as acceleration decreases.
- Do the opposite when bracking: pull the camera in towards the car in relation to braking deceleration, and gradually pull it back out as this decreases.

I've never tried this but am pretty sure it would give a more immersive effect. Hmmm, maybe I'm wrong and the idea sounds better that it looks. :P


_PJ_(Posted 2005) [#8]
Plus, it may be useful to have some invisible pivots at set places, and ensure the camera slides around them above, below, or to some side or the other. This gives dramatic angles at specific locations.


JoshK(Posted 2005) [#9]
The "pooper cam" excites me.


Barliesque(Posted 2005) [#10]
@big10p
I've had great results using that same sort of logic. I think about what kind of camera moves I'd ideally like to happen, and then consider in what circumstances they'd work best. Then I come up with a set of rules, much as you've described, using the speed/velocity/direction of the player. The results can be really very exciting.


Jeremy Alessi(Posted 2005) [#11]
There is a lot you can do with the camera ... look at the driver.bb code for a quick peak at a decent beginning. Take that and toy with it and you can get some very nice results. I think I did some decent stuff with Aerial Antics and Leadfoot GT all based off of that originally ... I guess the most exciting thing in AA is how the camera begins at the goal or end of the level and flies in toward the player.


big10p(Posted 2005) [#12]
Good to hear, Barliesque. Glad it wasn't just me talking out of my behind. :)

You got any demos floating about that feature your 'camera work'? They'd have to be pretty small for me to download, though - I'm only on a 56Kb connection. :/