I’m working on an On-Rails shooter game where the player controls a spaceship.
The environment includes closed sections with walls, effectively making the player fly inside a tunnel.
Now, one of the hazards that can be found in the tunnel is a “stomper”, which basically is a cylinder that moves and “stomps” on the ceiling, floor or side walls.
I want to make the environment shake a bit when the stomper stomps the environment. So far I’ve added a camera shake that I play when the stomper impacts the environment. However, this “moves” not only the environment, but the player’s spaceship as well, so it makes it look like the player has been hit, when the player is merely close to the impact point.
Is there a way to prevent the camera shake effect from affecting the player, as it’s flying and is not “pushed” by any vibrations propagated due to the impact?
I’ve not found a way to do this so far, and I’m open to suggestions about different ways to tackle this issue.
The player pawn follows a spline as the “forward” movement, while the player’s inputs control the “left/right/up/down” movement. I’m using a spring arm attached to the root component, while the camera is attached to the spring arm.
I understand that if you move the camera with the camera shake, everything in sight will be moved, including the player. So I’m wondering if there are any alternatives. If I don’t find a good solution I may resort to making some sort of animation on the enviroment where the stomper hits, but that may be costly.
Whenever you try to use a Camera Shake it will shake the camera itself, so it’s not possible to avoid shaking the player as well (visually, not really).
There are two different approaches I’d follow here to create some sort of “shake” just in the designated area:
The first one doesn’t requires any extra art or assets, it only changes the scale of the stomped object to make it look like it’s shaking.
To do it, I added a Box Collision to the Stomper and created a Timeline to change the scale for the Y Axis of my wall.
(I added the “IsExtending” check here so it doesn’t trigger more than once, as I set that variable false as soon as the Stomper reaches its target)
And this is the timeline:
(You can add as many values as you want to make it shake more)
k1: Time 0.0, Value 1.0
k2: Time 0.05, Value 1.2
k3: Time 0.15, Value 0.85
k4: Time 0.25, Value 1.1
k5: Time 0.35, Value 1.0
Of course you can use both approaches at the same time for a better result! You only will need to tinker with the values until you find something you like!
Thank you very much for your answer! What you are saying makes total sense. I’ll try to use both of these approaches, and see what gives the best results.