Forum rules - please read before posting.

Screen shake when character moves (2D game)

Hello!

I've been scratching my head with this one for quite some time. I have a large NPC character, that follows player. How can I make the screen shake when this character is moving? The shake should stop when the character is standing still.

What would be the easiest route to achieve this?

Comments

  • Welcome to the community, @ramboaslak.

    A shaking effect can be triggered at any time with the Camera: Shake Action.  Place this in an ActionList asset, and set the asset's When running field to Run In Background.  You can then call this whenever needed to shake the screen without interrupting gameplay.

    In order to have the screen shake in time with the NPC moving, you should be able to do this with animation events that are embedded in the NPC's walk animations.  While you could do it in a custom script, that would be the easiest way to time the shaking properly with the footsteps.

    An event or script that invokes the ActionList asset's Interact() function will cause that ActionList to run.
  • Thanks for the reply and welcoming me to the community, it's appreciated

    My background is with Visionaire Studio, so pardon me if I'm asking obvious stuff. So, I managed to add the animation event, but the function list doesn't include the Interact() function you mentioned. What's the next step? Should it be on the function list?
  • Apologies - I was mistaken about Animation Events.

    It seems they can only call functions that exist on the same GameObject as your Animator - so you will need to place the Actions in a Cutscene component placed on the same object.  Setting the When running field to Run In Background is still important, however.

    If you want to have multiple animation events that each run a different set of Actions, you would need to instead place a simple intermediary script on the GameObject, that can be used to run different ActionList assets based on a parameter supplied in the Animation Event.
  • Thanks a bunch! Now it works like a charm!
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.