Camera shake
So i wanted to make the camera shake thought with a nice post effect could look damn sexy...
got stuck on the code it doesn't like addoing object as camera
//shake.js
// Event: Frame Updated/tap/react
//adding for customisation
// @input float speed = 4
// @input float amount = 4
// @input SceneObject toShake
var newX = Math.sin(getTime() * script.speed) * script.amount;
var newY = script.yPos;
var newZ = script.ZPos;
//wrap in function for future calling
//function shakeObject(){
script.toShake.getTransform().setLocalPosition(new vec3(newX, newY, newZ));
//}
anyone got any thoughts may have to come back to this later during feeds and changes
Hey Patrick,
You’re very close! Since the camera object’s position/rotation will often get modified by other components (such as World Tracking or Gyroscope), it’s better to display the result of the camera and then modify the display so they don’t conflict.
The fastest way to do this would be to go into your Objects panel: Add New > Billboard. This will create a new billboard to display a texture.
Then, to display your Camera result: in the Inspector panel of your billboard, click “BaseTex”, then select “Camera Output”.
Since billboards covers the screen using an Aligner, in your script you want to access that instead of the SceneObject component.
Then instead of modifying the SceneObject’s transform, you can modify the binding point of the aligner
So your final script will look something like:
Using a speed of 40, and an amount of .10 I was able to get:
Can't wait to see what you come up with!
Jon
ah yea that makes sense my deadline passed for my project but I have another use i am sure....
Jon I have post in regarding date and time please would you mind looking at it. it's driven me crazy, again the deadline passed and I missed the requirements of my brief.
But I need to know!
.
Hey Patrick, Aww, Sorry about missing the deadline :( I went ahead and answered it the other post as well. I hope both of these can come handy in the future! Please let us know what cool stuff you make :)
Hi Jonathan,
I'm trying to achieve an effect similar to Patrick. Your code sadly doesn't seem to work for me. The only thing is does is slightly displace the billboard, but not animated.
Can you help me out here?
Hi Bram,
Hmm, what event are you setting the script to? The shake occurs because the billboard is displaced every frame. If it's only happening once, try setting the script to "Frame Updated".
If you're still having issues, would you mind showing us the script and how your project is set up (picture of the Object and Inspector panel) so we can take a look?
Thanks!
Jon
That did the trick Jon, you hero!