TheGameCreators / GameGuruRepo

The GameGuru Repository For Community Collaboration
http://www.game-guru.com
137 stars 56 forks source link

Camera shake when hurt #3118

Closed ZakJudges closed 2 years ago

ZakJudges commented 2 years ago

In my opinion, the new camera shake that happens when the player gets shot should be much more subtle to make it more like a 'flinch' reaction. It should also have an option to toggle it on/off

AmenMoses commented 2 years ago

Camera shake should use Perlin noise (and should be disabled for VR!) and work on camera rotation rather than position.

A flinch is an actual player camera position change rather than a shake.

Cine|Guru has proper cinematic camera shake based on Perlin noise btw. The Perlin noise library in Cine|Guru is effectively open source as it is a Lua version of the original code, let me know if you need a copy of it.

LeeBamberTGC commented 2 years ago

@AmenMoses Do you want to have a go at replacing the NegOneToOne random values to use perlin? The technique I used was from a GDC talk a few years ago for trauma camera shake, but they did not go into detail on how they created their random values :)

AmenMoses commented 2 years ago

Seems like the maximum value I can use with SetGamePlayerControlCameraShake is 25 (i.e. I can put larger values but GetGamePlayerControlCameraShake reports a maximum of 25.

https://vimeo.com/710530712

As you can see in the video the effect is not very good at 25.

I'm using a simple script that when you press E it calls GetGamePlayerControlCameraShake() btw.

AmenMoses commented 2 years ago

https://vimeo.com/710904400

Bypassing SetGamePlayerControlCameraShake in this video and generating an earthquake effect.

Is this what you are after?

LeeBamberTGC commented 2 years ago

@AmenMoses A good shake :) @ZakJudges How does this compare with the most recent one you edited?

AmenMoses commented 2 years ago

Btw, shake requires 3 variables, the amount to apply (trauma) the amount by which it abates each frame (fade) and the rapidity of the shake effect (period).

I have added functions to gameplayercontrol.lua in order to allow these to be set from other scripts whilst still honouring the SetGamePlayerControlCameraShake function (which under the covers simply calls the new AddGamePlayerControlShakeTrauma( num ) function).

In the video the trigger script simply turns a permanent shake on and off using E key press and the values used are 40 for trauma and 100 for period. (the trauma range is 0 .. 100 and can either be set to a level as in the video or added to over time and allowed to fade naturally)

Small values for period give a short sharp shake, large values result is a more gentle shake so 500 for example can be used for a sort of drunk/drugged/wounded player effect.

For an explosion shake I would use a large trauma value (probably dependent on how far away from the player the explosion occurs) and a period of 50.

The values for other effects would be a case of trial and error to find out what looks best.

If @ZakJudges wants I can send the altered gameplayercontrol.lua and Perlin noise scripts via discord to play around with.

AmenMoses commented 2 years ago

https://vimeo.com/710952020

In this video the values I've used are 35 for trauma, 3 for fade and 30 for period.

Towards the end of the video I hammer the E key to show the additive shake effect.

Btw this video also shows another strange bug, when Bob starts moving he sort of takes an instant rotation to the right for some reason I can't fathom. Also at the end of the action Jane is supposed to be looking at the player but instead is looking to her left. Works perfectly when on the terrain so I assume it is something to do with them being inside a building or maybe the elevation?

ZakJudges commented 2 years ago

@AmenMoses Sure thing, send away :) I really like the additive shake effect

AmenMoses commented 2 years ago

I’ll send it later on Discord (when I’m off work), I take it you are Zak on Discord.

On 18 May 2022, at 09:56, ZakJudges @.***> wrote:

@AmenMoses https://github.com/AmenMoses Sure thing, send away :) I really like the additive shake effect

— Reply to this email directly, view it on GitHub https://github.com/TheGameCreators/GameGuruRepo/issues/3118#issuecomment-1129750258, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQN3MTNSUU3RJ6S5KEZEYLVKSWCRANCNFSM5V3MJKJA. You are receiving this because you were mentioned.

ZakJudges commented 2 years ago

@AmenMoses Yes that's the one. Alternatively you can reach me at: zak@thegamecreators.com thanks!

AmenMoses commented 2 years ago

Sent you a friend request on Discord.

On 18 May 2022, at 12:45, ZakJudges @.***> wrote:

@AmenMoses https://github.com/AmenMoses Yes that's the one. Alternatively you can reach me at: @. @.> thanks!

— Reply to this email directly, view it on GitHub https://github.com/TheGameCreators/GameGuruRepo/issues/3118#issuecomment-1129906645, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQN3MQ7WBSU2VOLGBANPSLVKTJ4VANCNFSM5V3MJKJA. You are receiving this because you were mentioned.

AmenMoses commented 2 years ago

https://vimeo.com/711368241

Video of the latest, two types of shake effect here, the slow drunk cameraman effect with sharp shocks overlaid.

Zak has this now so he can play with it and see how it looks with the 'hurt' effect.

LeeBamberTGC commented 2 years ago

@ZakJudges Do you want to take the latest EXP build script and make the changes as discussed here, and we can then look at how we can expose some settings through the player start marker (in developer mode) to give users the final choices. Thanks!

AmenMoses commented 2 years ago

The 'final choices' will depend on what triggers the shake and what effect is required, it would make more sense to use behaviours with dynamic Lua settings attached to trigger objects such as zones or other markers, or even to link trigger objects to behaviours.

For example link an explosive barrel to a camera shake trigger marker with the settings on it, so that when the barrel explodes it will trigger the shake effect based upon the settings selected.

For generic use, such as player being shot or punched then it should be a simple 'enable shake effects' button on the start marker and the values themselves should be preset to give the best effect.

Oh and for VR, when that is finally re-enabled, all these effects should be automatically disabled!

Btw, if 3rd person makes a re-appearance these sorts of effects will need to be revisited as they are even more effective in 3rd person than in 1st person but need to use different values and for some effects it is camera positioning that needs to be changed rather than rotation.

As has been pointed out in discord discussions, effects like flinch should change the player/camera position in addition to rotational effects, also things like player being sick/drunk/wounded also benefit from positional changes to mimic stumbling/tripping (this would also use Perlin noise, just like they do in Hollywood).

AmenMoses commented 2 years ago

One last comment for tonight, the gameplayercontrol.lua script I sent Zak was the latest I had from the experimental build, do I take it that you have also made other changes in the last few days? If so it may be more sensible for me to be given the latest one with any changes you have made to integrate as I had to make a few other tweaks to get it working properly.

I also put the footfall and third person parts in separate functions to make it a bit more readable so you will probably find it difficult to just do a diff!

LeeBamberTGC commented 2 years ago

@AmenMoses The gameplayercontrol script on EXP Build right now is the very latest, and I will not be changing it again until Thursdasy 10 AM GMT at least. Not sure if that is a sufficient window but yes if you can merge your best with our latest, it is a nice win :)

ZakJudges commented 2 years ago

@LeeBamberTGC I have emailed you the updated files. Just need to decide which settings will be exposed to the end user and in what situations the shake will be triggered :)

LeeBamberTGC commented 2 years ago

@ZakJudges In and working nicely for this weeks build :)