#muzzle flash and recoil syncing

1 messages · Page 1 of 1 (latest)

rigid jacinth
#

i'm trying to sync up the muzzle flash to the recoil animations, it's close but i'm running into an issue where it's not activating in time. No matter what I do the recoil animation is starting before the muzzle flash, just curious if anyone had tips on where I should be triggering my VFX graph so that my muzzle flash is being triggered at the same time as the recoil, currently I have it scripted to activate muzzleflash when private void OnFirePressed is activated in the FPScontroller, and deactivating with OnFireReleased, I appreciate any help!

https://streamable.com/qtgks0

rigid jacinth
#
private void OnFirePressed()
        {
            muzzleFlash.Play();

            Fire();

            _bursts = GetGun().burstAmount - 1;
            _fireTimer = 0f;

        }

        private Weapon GetGun()
        {
            return weapons[_index];
        }

        private void OnFireReleased()
        {
            muzzleFlash.Stop();
            _recoilAnimation.Stop();
            _fireTimer = -1f;
        }
eager stump
#

What's preventing you from triggering both at the same time? In your example code you have _recoilAnimation.Stop(); in OnFireReleased(), but you don't have _recoilAnimation.Play() in OnFirePressed(), why not? Where do you start the recoil animation?

rigid jacinth
#

recoil animation is in the weapon script by default, and gets pulled into this FPScontroller script under Fire(); I didn't change those at all, i'm just trying to figure out the best way to trigger my visual effect so it syncs up

#

the recoil animation triggers great, the problem is the muzzle flash not triggering every time the mouse button is clicked and i'm not sure why

eager stump
#

Ahh, then my suggestion is to either write your own code from scratch or to rewrite the code to do what you want 🙂 The example project in this asset is just that - an example of how the asset can be used. It's extremely simple and rough. You shouldn't treat it as set in stone.

#

I haven't looked at this asset or example project in a while, so I downloaded them now, and it looks like the recoil is played inside Fire(); in your code there so it should be playing at the same time as your muzzle flash. Then I don't know. Hard to say without debugging it.

#

And I've actually broken the recoil in my own project so I can't check for you right now 😅

I'm currently not working on this project so I can't promise a fast update on this. Maybe someone else can help you.

But in general. Not to talk too much smack about the asset author since I think this asset is extremely promising, but there are quite a few rough corners, so don't assume the asset is perfect and your own code is at fault. The error could very well be inside the asset itself. You just need to step through the code and see. The recoil animation is one of the more code heavy parts pf the asset so it could be a bit challenging to do, but that also means there's a higher likelihood of bugs in it.

rigid jacinth
#

right on yea i've been trying to trigger it in a lot of different places but just keep coming up with different problems, the asset has been fantastic but definitely hitting a few obstacles trying to make things work, would be neat if there was a serialized field or something in a future update telling you where a muzzle flash could be implemented in a future update since the recoil system is already built in, i appreciate the feedback and tips, i'll keep messing with it and hopefully come up with a solution

eager stump
#

Good luck, but just to be clear. What I meant is that since there is currently no working example of muzzle flashes or bullet spawning in the asset there's no way to be sure the recoil code actually is able to do what you want. For all we know it doesn't work correctly. Not saying it doesn't, but just to have the mindset that it's a possibility 🙂

I just looked at my own code where I had assumed I called Play() on the recoil animation for every bullet I fired, but I actually currently do it the same way as the example project, and the code snippet you show here, where I Play() the recoil when I click the mouse button, and Stop() the recoil when I release the mouse button. That doesn't work in my project at least since there's no guarantee a mouse click produces a bullet, and even if it does the rate of fire for my automatic gun could be anything so I'm not sure how that would work. So even though I can't verify this since my recoil is currently not working at all, I have to assume that even if it was working it wouldn't work correctly.

I see there is some information in the documentation though: https://docs.google.com/document/d/e/2PACX-1vQNAFV10w_YBCmjsuR3Q93uq30QYyYNDsq3UZygpkAAcOQR6LU_sO1LVbDHtD5-ilvgOPEPgYvPLbAF/pub#h.za1nr9ryldrq

Looks like for automatic fire you need to ensure that the recoil curve matches your rate of fire. I've definitely not done that in my project :p And that sounds like a bit of a hassle to me, so I may end up just using a simpler approach to procedural recoil that doesn't involve maintaining curves.

But I haven't spent much time on the recoil aspect yet. I'll let you know if I do and if I discover anything of interest.

rigid jacinth
#

Yea they have been great with support and updates and i'm already much further along than I would've been if I had started from scratch so I really can't comlain haha that actually gives me an idea on try triggering the muzzle flash within the actual recoil animation script tho instead of the FPScontroller or weapon script