Forum rules - please read before posting.

Handheld Camera Effect

edited September 2020 in Technical Q&A

How would I go about doing something like that?

I can't use the Shake() method, I want something slower, smoother and I need an infinite loop.
I can't tween the main camera myself as the transform position gets overwritten in MainCamera.cs script.
It's a wide screen with horizontal movements unlocked. Player is target.
If both horizontal and vertical movements are locked I could possibly crossfade multiple cameras in a loop.
Anyway I'm wondering if there's a way of achieveing that or is this where shaders come into play?

Thanks for suggestions.

Comments

  • edited September 2020

    I use Cinemachine for cameras that need shakes. It might be a little bit of work to integrate in your setup, but Cinemachine has some great camera shake settings (alongside decent dolly/tracking cameras).

    https://adventurecreator.org/forum/discussion/7397/cinemachine-workflow

    https://learn.unity.com/tutorial/cinemachine

    You can also create an animated camera and create a looping camera shake if you want to stick with Adventure Creator only.

  • @machineboy Thanks for the info, I'll look into it.

  • Yes, aside from Cinemachine it can be done with an AC GameCamera and animation.

    An AC GameCamera will control that GameObject's Transform values, but the Camera component itself can be on a child object. So, if you move your GameCamera's Camera to a child, you can attach an Animator to the child to add a subtle movement effect without interfering with the GameCamera's position, rotation etc.

  • @ChrisIceBox Oh, I can animate/tween the parent object. Well, that's all I really needed. Thanks!

    @machineboy I've tried the Cinemachine package. I just had to add Brain component to my AC's camera and create a virtual camera with some noise. It was working right out of the bat.

    The handheld noise is quite nice. Thanks for the tip :)

    The only thing that confuses me is that the z-position (2d game) of the virtual camera determines whether it will just move around or distort the image. Weird.

  • Update: I misread the message. It's not animating the parent, but the child.
    Anyway moving the camera to a child was not possible with GameCamera2D, only with GameCamera.

    But all I had to do was switching the camera to Orthographic and setting the GameCamera's Affected by value to Side Scrolling and it was working just as the regular GameCamera2D.

    Unfortunately I was not able to get everything working properly with Cinemachine.
    Player target, axis locks and contrains and parallax affected by the handheld shake.

    So I've decided to go without Cinemachine and animate the child camera object as suggested.

    To get similiar randomness that Cinemachine provides, I've animated the camera via script with Perlin noise.
    Here's the script if anyone's interested https://pastebin.com/550a33E8

    Now, everything is wokring the way I wanted. Thanks for help!

  • Thanks Keks! Just used your code and it works great!!! ;)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.