Camera Shake

Blitz3D Forums/Blitz3D Beginners Area/Camera Shake

CodeOrc(Posted 2008) [#1]
I have searched the forums and Code Archs and have had no luck finding an example code for a camera shake.

Do any of you have one collecting dust on your HD?

thx :)


Naughty Alien(Posted 2008) [#2]
here is basic working example..

Function Shake_Cam(CameraE,shakesize)

PositionEntity CameraE,Rnd(-shakesize,shakesize),Rnd(-shakesize,shakesize),Rnd(-shakesize,shakesize)
If shakesize > 0
shakesize = shakesize - .05
Else
shakesize = 0
End If

End Function


Kryzon(Posted 2008) [#3]
Instead of position I'd recommend Turning on the X and Y axis.
Or even join both, if you really want it messy.


GfK(Posted 2008) [#4]
Probably easiest to shake the viewport rather than the camera.

Depends on the effect you're after.


Kryzon(Posted 2008) [#5]
But that way you'd get to see the black background.


CodeOrc(Posted 2008) [#6]
well, the effect I want is when I get clobbered or shot by a BFG, I want my cam to shake to the ouch factor.

what are you guys doing for it? ...any code examples? Or is cam shake too old and not used anymore?


Zeotrope(Posted 2008) [#7]
I use cam shake on rocket splash damage. Mine is effected by the proximity of the camera (you) to the explosion.

I dont use moveentity or any viewport tweeking....I use Camerapitch / Roll and Yaw.

"Or is cam shake too old and not used anymore?"

You still see this effect everywhere from Movies to Games. Could be used to simulate the 'thud' of a dinosaur walking along side of you....watch out for the droppings though.


CodeOrc(Posted 2008) [#8]
@ ThermO > Would it be too much to ask for you to post an example of your cam shake system?

Not your entire code as I am sure you wish to protect it from being pilfered unless of course you want to :)

I will begin bashing away at my own system in a couple days if no one is able to provide a sample....wish me luck.


Zeotrope(Posted 2008) [#9]
My code, which is at home (I am at work) really isnt that complex.
I must also clarify the Pitch / Roll and Yaw...these are effected via the turnentity command.

Try something like...(theory only)


If Entitydistance(camera,bomb) < 10 ; if you are close to the explosion

shake_rnd_a = rnd(5)+ 1 : shake_rnd_b = rnd(6)+ 1 ; load 2 variables with random numbers etc

Turnentity camera,shake_rndx,0,shake_rnd_b ; apply the variables to the camera's 'turn' command (not rotateentity)

Endif 



I cannot test the above code and it really requires 'floats' and a lot more variations....but I am sure you get the principal.

For a simpler approach, try applying random rumbers to the camera's turnentity command, without worring about creating explosions and being concerned with proximity etc. You need to study the effect and what is happening before proceeding.