This asset is FREE now.
You can check out from Github
I have too little time to maintain it. Bugs can’t be fixed in a hurry as old time.
It needs help from community.
DONT BUY IT IN ASSET STORE NOW. IT’S GOING TO BE FREE.
Thank you all.
This asset is FREE now.
You can check out from Github
I have too little time to maintain it. Bugs can’t be fixed in a hurry as old time.
It needs help from community.
DONT BUY IT IN ASSET STORE NOW. IT’S GOING TO BE FREE.
Thank you all.
A badly needed component for using mecanim - will give this a shot after xmas here, thanks G1!
Hi G1NurX,
I’m a bit of a noob here.
I did set everything up as discribed (I think.)
I have Two Events on an animationclip, at it’s start and end with the same name.
The first with an Int32 set to 1.
The second with an Int32 set to 0.
Now I want to play a soundclip when the Int32 is set to 1 and stop it when it’s set to 0.
In javascript. Could you tell me how to do that? I simply don’t know.
Thank you.
I’d like to add the first event named PlaySound and the second one named StopSound.
In your case, write a function, for example, Bang with an int argument.
Attach the script contains this function to the gameobject emit the event.
Thank goodness! I can’t wait to download this and see how it works. I’ve been struggling with trying to get footsteps in Mecanim for the past hour using curves. That feature is not implemented as well as I had hoped from watching the Mecanim demo videos. It’s advertised as a way to manipulate data, but the values returned are not reliable, so it’s really only good for tweening animations in blend trees and imprecise scalings for colliders.
You are the best! Expect a purchase in the next five minutes.
G1 - Can your event system guarantee that an event is called? I’d like to see it where if I define a method “OnFire” @ 0.95 time index, I can check off an option to ensure that OnFire will be called once each time the animation is played regardless of whether it is reached or not. This way we can rely on the fact that any time I hit a particular state in the state machine, i’ll know that i’m gauranteed to receive a callback by the end of it for each “guaranteed” method.
The reason for this is because if we have some code that must be executed to keep our games state valid, we could rely on an event coming back. For example, I currently have several states for weapons/combat, to keep it simple called two FIRING and READY. When the player hits the fire button, I set the state to FIRING - this blocks ALL attempts at reloading, firing, etc… again until we are back in the READY state. For each of the firing events, I have a OnFireStart and OnFireEnd. The OnFireStart is not critical, it just produces the muzzle flash and sound at the correct time in the animation to line things up nicely. The OnFireEnd however, is critical, it resets the weapon back to a READY state.
Currently I’ve tried getting state lengths, etc… to handle this, the best I’ve come up with is having a recoverTime which is Time.time + fireDuration, then check this in the Update loop and reset to READY if the OnFireEnd event is missed.
However, having the notion of an event which is guaranteed to be executed once each time the state is visited - would be great, even if the event is placed near the tail end of the animation and that animation is transitioned from before the event is reached (in this case, as soon as we leave the pure state and start to transition, execute all outstanding ‘guaranteed’ events).
I can handle this in my own code here, but imo this feature would make for a very solid event handling asset.
Excellent asset G1. I’ve been rather surprised that this functionality was missing from Mecanim.
Also I second Lypheus query. ![]()
Hi, Lypheus
I used to reset a state at the beginning. For example, a mob has a state named hurt. The mob will transit to hurt state - set Hurt parameter to true -when it received a damage event. Then I raise a ResetHurt event to set Hurt parameter to false at the beginning of hurt state by event system. Hurt state will automatically exit when it reached ExitTime - a parameter defined by engine. In this way, hurt state won’t be triggered again until another damage event handled.
Actually, I took this functionality you mentioned into consideration in the first released version. But some unexpected behavior is will be encountered because of blend-tree. I removed this guarantee finally for stability.
If you think this guarantee is very necessary just send me an email to confirm. I’ll work it out in a few days and send you a branch version.
Ya I’m not sure what the best approach is for that, I mean what I currently do right now is to assign durations to each “timed” attribute of my weapon (draw time, holster time, fire time, reload time). Then, using those I setup a “clearToReady” time for the gun, and a “lockAnyState” variable to block any re-entrant attempts at the animations until its “ready” again.
Instead of using all those events, my approach is to simply start a coroutine and wait two frames then set the “Hurt” parameter back to false so it’s as “set and forget” as I can make it, something like:
public IEnumerator ExecuteFire( Animator animator, float fireRate )
{
// yield a couple frames for animator to start next state transition
yield return new WaitForFixedUpdate( );
yield return new WaitForFixedUpdate( );
// next, clear animation flags to ensure no sequence repeats
animator.SetBool( "firePrimary", false );
animator.SetBool( "fireAlternate", false );
}
I don’t know what the best approach is here, IDEALLY I’d like to be able to control the state duration from within code, so then we’d at least be able to fetch projected state duration and then set the time to clear back to ready as the current time + state duration. But I see no way of handling this with mecanims current API (am I missing a reliable way to find the duration of a state? state.length seems to not be it
).
Anyhow, with regards to guaranteed events - if what you roughed out was not reliable, i’ll keep on with existing code here and go that route, but it’d be nice to see something like this in the future.
Mecanim missing the feature to scale a specific state at runtime. It can only scale animations globally.
You want to control the duration within code, but I doubt will animation be played completely without scaling.![]()
Hey G1, just purchased this and so far so good…couple of notes:
Would be nice if the editor automatically loaded the last Controller you were working on. For a brief moment I thought I lost all the work I had done, then realizing I had to load the controller again. Not a big deal, but a nice ‘detail’ if it’s easy for you to implement.
Any reason why there isn’t a boolean parameter? Sure I can use an int32 and pass a 1 or 0, though a bool option would seem like another ‘nice detail’ to have, and it would parallel Mecanims available parameters.
Thanks G1
EDIT: Oops forgot a BIG one!!
Ah, didn’t notice this during my cursory first-use!
Thanks again G1
-Steve
Thank you for your support, Steve
I will merge this feature from branch into trunk in a few days.
It does what legacy system does. But I think it is necessary in order to make this system convenient. So boolean type will be supported in next release.
I will make it better.
Events were added to the state that contains the blend-tree, but not for a specific animation clip. Events will be raised in normalized time. Footsteps can’t be a problem if animation clips are synchronized - scaled into homogeneous time.
Hey G1, good news all around then, yay!
…except number 4; I didn’t quite understand what you’re saying.
Either way two things are currently a problem regardless of time throughout the animation:
A) I will want to have different events fire for different animations within a single blendtree, which has nothing to do with time, and not necessarily just footsteps or even sounds at all. This is why it makes more sense to have events fire on the animation level, not just time.
B) Currently I can’t see my entire tree of blended motion to ensure event timing…I only see the first animation out of say 20. This problem furthers the case of per-animation events.
Thanks G1
-Steve
I’m sorry that there is no way to add events to a animation clip within a blend-tree.
All animation clips in a blend-tree are running simultaneously. There’s no boundary among them - they were blended linearly. Let’s assume that I added a event to run animation, but this event will be raised even if character is walking. It’s not we expected.
To solve this problem my opinion is that don’t use blend-tree unless all animation clips within it share the same events.
I understand what you’re saying, but there’s always a solution, even if limited.
You could simply impose a strict event return based on anim weight; we won’t have “event-blending”, but simply enforce a priority based on which animation has the greatest effect on blending.
In other words if you have two animations, blended at 60/40, the animation that is weighted at 60% would have it’s events executing.
Perhaps instead of events on a per-anim basis, you could use conditional events based on where we are in the blendtree. You still have the linear aspect of your event firing as it currently is, but then based on parameter input, just as Mecanim uses, events could be fired if and only when a parameter condition is met. This would still require we be able to preview our entire blendtree when creating events, not just the first animation.
Regardless, Mecanim’s primary strength, even the reason it exists is it’s sophisticated blending. Limiting events to a single level is rather restrictive and asking to not use animation blending is unrealistic.
There’s always a solution G1, even if not ideal, so I hope you consider this.
Gin and I have been working on improving this tool, and is definitely what you’ll want if you plan on using Mecanim to any great degree. He should be updating both the asset and improved documentation to understand how to use it better.
Cheers
-Steve
PS. Oh and for clarity, I’m just a customer who pestered him privately into working more on it…and now I’m pretty satisfied so I wanted to make sure people knew this.
This is a really helpful feature! In the next version, could you include the parameter? Right now, I have an event like this:
Message: ClearBool
Parameter Type: String
Parameter: Jump
In the list, it shows as “ClearBool@0.0100”.
It would be very helpful if it showed as “ClearBool(Jump)@0.0100”.
Thanks!
Looks like a great asset. Buying. And I’m glad the dev is able to work with customers in Steve B’s case
It would be great to be able to copy events from one state to another. For example, i have a left leg kick and right leg kick (mirror), they have the same events, in the same time, such as raised his leg, and it would be great to just copy the existing events from other states.