Camera shake behaviour multiple layers?

good day I using the camera shake behaviour and my scene has allot of different layers but I can only reference a specific layer? how can I have for multiple layers?

The camera shake behavior doesn’t do anything that you can’t do with events. Because each layer has a unique camera, the extension isn’t going to be able to call all layers at once, since they’re not the same camera.

You would need to use an event for each layer, with the same setup, if you want them to shake the same.

I have to create my own camera shake event?

No, the camera shake extension adds the events to the engine for you.

You have to add a camera shake action for each layer you have. Just like any other camera events /conditions/actions that you want to impact each layer.

ok I added a second event layer but only the last event working not both?

events

Honestly, I’m surprised either are working. You’re telling it to shake for 1 second every frame, which is going to break.

You can have both actions in the same event, but they really need to have some form of condition, like trigger once, or something else that activates them for a limited time, since right now you’re starting infinite shakes which will eventually break your game.

I’ve tested with the Not-A-Vania example, and as long as you’re not typing the layer names and selecting the layers from the list (to avoid typoes), it works fine.

Here’s the example with 3 layers shaking after 2 seconds:
https://game-previews.gdevelop-app.com/1648037076660-892638/index.html

ok thanks for the example! I thought not having a condition maybe the problem so I did try trigger once but got the same result. I copied your example but still only works for the last action in the event and not the rest?

Unfortunately, I can’t give much guidance since I can’t reproduce the issue.

Few questions:

  • You’re using a “Shake” timer. Did you properly start that timer somewhere else? Timers aren’t automatic so they have to be created elsewhere.
  • Do you have anything in the background1 and background2 layers? They’re not just empty layers, correct?
  • are they actually layers? The action you’re using is for layers only, so if you’re putting in object names it won’t work

ok thanks to answer your questions: 1. I was using an older timer method (which works) but did try the newer timer and still the same result. 2. I checked the objects are in the correct layers. 3. definitely layer names and not object names.

shake timer event

could be how I set up my camera follow events?

Big huge disclaimer: The old timer methods should no longer be used for new events as they are not reusable in new projects and are no longer supported. If they’re working for you, that’s totally fine but keep in mind they’re basically considered legacy, so I cannot further help you there.

Disclaimer out of the way: I’m not positive, but I wouldn’t be surprised if you cannot use the camera shake actions when the camera is in movement. Basically, your “Center camera” actions are going to conflict with your “shake camera” actions.

You probably have to move each “Center camera” action for the layers you want to shake into their own events, and ensure they have the condition “Camera is shaking” in the event, inverted.

thanks for the update on timers I should change them over. I started a new project with nothing except adding the object to layers and install shake camera behaviour but still only the last event layer works :sweat:

EDIT if you want I uploaded the project here you can check if it works or not?

For some reason I cannot access the site (likely DNS issues in my area). Can you post a screenshot of your normal camera events and your shake events in this project?

I don’t have any camera events? the only event is what I have that’s all the project is but still not working more than 1 layer.

scene

events

Hmm…not sure. If it isn’t working for you, you’ll probably just need to develop your own camera shake events. The events themselves aren’t very complex, there’s an included example in the engine, too.

I know this extension was made by @tristanrhodes , but I’m not sure if they have any input on why it works in some instances but not others.

1 Like

I’ve had a look into the camera shake extension, and it sets a global variable to the name of the layer passed as parameter. It then keeps updating the camera position for the layer name in that global variable. As you’ve calling up the shake action 3 times, the value this global variable gets set to is the one passed by the last action - “Layer3”.

In short, the way the extension is currently programmed you can only apply the shake to one camaera/layer at a time.

@Shadow_Assassin, if you want multiple layers, you’ll need to modify the extension. Your best bet would be to store each layer’s shake parameters in a structure, with the layer name as the key/parent node. I can give it a shot if you like. Let me know.

2 Likes

thanks I was also thinking that and had a look at the extension and did see global variable but don’t know how to change. I don’t know why it works for @Silver-Streak then? please give it a go thank you.

Thanks for chiming in on this. This makes sense, although It doesn’t make sense why it works in my example above (all of the moving objects are on different layers).

Now I need to check into why it works there. :thinking:

Edit: Now I know why. I have my camera layers use the base layer as their position, rather than manually centering them all.

So my BG1 layer is centered on CameraX("",0) and CameraY("",0) (as is BG2) so I don’t have to worry about object selection. Since the base layer is shaking, the additional layers are shaking when the base layer shakes.

It seems like @Shadow_Assassin 's layers are all centered on the same thing and shaking off the same interval, so that may be another easy workaround for now, too.

1 Like

thanks ok not sure I understand how do I center the camera layers to one layer?

You can look at how I do it in not-a-vania, but in general, you would use the “Center Camera X” and “Center Camera Y” actions, using the expression for “Camera Center X/Y” as the target (CameraX/Y()), selecting your base layer as the target for the expression.

Yes, the current version of screenshake only works for one layer at a time.

It needs to be updated to accept the layer as a parameter, and then store all the existing variables as structure variables under the layers.