poewang13 Posted November 16, 2017 Report Posted November 16, 2017 I saw this code and animation have a event point if (animator == null) { animator = FindObjectOfType<SpriterDotNetBehaviour>().Animator; animator.EventTriggered += e => Debug.Log("Event Triggered. Source: " + animator.CurrentAnimation.Name + ". Value: " + e); } and I want to add this code private void GiveDamage() { enemy.GetComponent<Enemy>().TakeDamage(10); } How can I add this code to event point ,in animations.I check examples ,some animations play a audio clip but I didn't see anything about adding function Thank you for all answer Quote
loodakrawa Posted November 16, 2017 Author Report Posted November 16, 2017 3 hours ago, poewang13 said: animator.EventTriggered += e => Debug.Log("Event Triggered. Source: " + animator.CurrentAnimation.Name + ". Value: " + e); This line literally is registering a function to the event. Try animator.EventTriggered += e => GiveDamage(); Btw, this is basic C# - I recommend reading about Delegates, Events, Actions and Funcs. Quote
poewang13 Posted November 17, 2017 Report Posted November 17, 2017 On 17.11.2017 at 1:02 AM, loodakrawa said: Btw, this is basic C# - I recommend reading about Delegates, Events, Actions and Funcs. Sorry about that . I completely forgotten Delegate,my mistake Bu I have 2 event point in animation and I try this animator.EventTriggered += e => ActiveObject(); animator.EventTriggered += e => DeActiveObject(); In unity, I see two functions same time but I want to see this two func. in different time.For Example in 100th Frame I must see ActiveObject func. ,1600th frame ,I must see DeActiveObject func.In the inspector I can see different Id but I don't understandt how can ı use them another an questions I have 2 animations ,first animations have 2 event and second animationd has 1 event .How can I set this event my 3 functions ? Thank you for answer Sorry about my bad english Quote
Pino Posted February 11, 2018 Report Posted February 11, 2018 Hi, I got Spriter on Steam and I've been having fun creating some nice animations I really needed for some artwork that I have here. Having finished up I brought all to Unity and... the skins deformations are not showing... all invisible Am I missing something stupid here? Quote
Mike at BrashMonkey Posted February 12, 2018 Report Posted February 12, 2018 59 minutes ago, Pino said: Hi, I got Spriter on Steam and I've been having fun creating some nice animations I really needed for some artwork that I have here. Having finished up I brought all to Unity and... the skins deformations are not showing... all invisible Am I missing something stupid here? Skin mode es an unofficial experimental "proof of concept" feature and is not supported by any of the API-s or run-times. Your options are: 1) Don't use skin mode 2) Use skin mode as much as you want, but then export all animations as full frame sprite-sheets or sequential images and therefore not benifit as from tweening and modular animation related things like drastically reduced memory consumption. 3) come up with a clever work-flow that uses skin mode to pre-create some image-swapping animations for parts of your final Spriter animations... This requires two spriter projects... the first using skin mode, then a second with any skin mode animated thing replaced with sequential images exported from the skin mode version. I used option number 3 to make the animated flags in the Dreamland Frontiers Art Pack. Quote
DietChugg Posted July 23, 2018 Report Posted July 23, 2018 Hi, I'm a user who's been excited anticipating Spriter 2's free form deformation tools. Will there be Unity support for that feature on Spriter 2's Launch or will that come later? Quote
Einar Posted October 10, 2018 Report Posted October 10, 2018 I've been using Spriter with Unity lately, and both the Spriter program itself and the Unity wrapper by loodakrawa are a joy to use. Performance-wise it seems to be a winner as well. I use events and points a lot, in order to control a lot of custom sprite swapping and other jazz in Unity, and I've encountered a couple of bugs/oversights/"features": 1: A Spriter-point, when converted to a unity object, does not get the correct rotation (it's always at zero degrees). I've fixed this by adding the following line to UnityAnimator.ApplyPointTransform (at line 138 in my case): pointTransform.localEulerAngles = new Vector3(0, 0, info.Angle); 2: A Spriter-point with limited duration (for instance it only exists at frame 60) will not be set if that particular frame is skipped in Unity. In my case the point was only visible/discovered by the system every tenth iteration or so. This is probably not a bug per-se, and easily circumvented when I know about it, but I thought I should at least mention it. Cheers, Einar Quote
Vincent Laugier Posted December 10, 2018 Report Posted December 10, 2018 Hi, I'm trying to do the following (in Unity): pause a running animation resume a paused animation jump to a given key of an animation hook to the end of an animation (in order to notify that the animation has stopped playing) EDIT (some solutions): To hook to the end of an animation, see 'AnimationFinished' in Animator.cs For jumping to the given key of an animation, here is a solution that works for my use case, I added the following function in Animator.cs (it's an adaptation of the 'Play' function) /// <summary> /// Go to key and stop /// </summary> public virtual void GoToKeyAndStop(SpriterAnimation animation, int keyRankFrom0) { // Use the first timeline to get the keys SpriterTimeline spriterTimeLine = animation.Timelines[0]; Time = spriterTimeLine.Keys[keyRankFrom0].Time; Speed = 0f; // will make the animation stop (=> you need to set 'Speed = 1f' in the 'Play' function) CurrentAnimation = animation; Name = animation.Name; NextAnimation = null; Length = CurrentAnimation.Length; } Quote
loodakrawa Posted January 16, 2019 Author Report Posted January 16, 2019 On 12/11/2018 at 2:10 AM, Vincent Laugier said: Hi, I'm trying to do the following (in Unity): pause a running animation resume a paused animation jump to a given key of an animation hook to the end of an animation (in order to notify that the animation has stopped playing) EDIT (some solutions): To hook to the end of an animation, see 'AnimationFinished' in Animator.cs For jumping to the given key of an animation, here is a solution that works for my use case, I added the following function in Animator.cs (it's an adaptation of the 'Play' function) Hi, As you already figured out you can pause and resume by setting the Speed property. For the end of the animation - Animator.cs exposes the AnimationFinished event which you can subscribe to. As for jumping to specific keys - what's the use case for that? Could you achieve the same effect by splitting the animation into several smaller ones and then just switch animations instead of jumping to different keys? Quote
think1st Posted March 7, 2019 Report Posted March 7, 2019 How up to date is the Unity implementation in the repository? Its readme still states that development of it is on hold. Quote
Mike at BrashMonkey Posted August 28, 2019 Report Posted August 28, 2019 On 7/25/2019 at 3:55 PM, IanThePsycho said: some of the code is obsolete, tried to fix it but still not working. We've recently tested quickly with the latest version if Unity and it seems to be working. If this is not the case can you please report specific error messages, bugs, etc? Quote
SquigglyFrog Posted August 4, 2020 Report Posted August 4, 2020 Not to necro, but still looking for a solution. I have tried setting the animator.speed to 0f, and it continues to animate. If i set it to 0.25f, it definitely slows down, but setting it to 0 seems to do nothing. Quote
Mike at BrashMonkey Posted August 11, 2020 Report Posted August 11, 2020 On 8/5/2020 at 12:32 AM, SquigglyFrog said: Not to necro, but still looking for a solution. I have tried setting the animator.speed to 0f, and it continues to animate. If i set it to 0.25f, it definitely slows down, but setting it to 0 seems to do nothing. Sorry that at the moment we can't offer any first part support for the Unity run-time or importer. We'll try to resolve that as soon as we can, but it might not happen until after the next few Spriter update builds are released. In the meantime, can you confirm you're using SpriterDotNet.Unity with the latest build of Unit and it's mostly working, but you can't find the way to completely pause animations? Quote
SquigglyFrog Posted August 17, 2020 Report Posted August 17, 2020 yes, definitely using spriterdotnet.unity with unity 2017, 2018, and now 2019.4.8f1. So mostly figured it out, I didnt change my code at all, but upgrading to a diff ver of unity did fix that issue. Now if only unity and spritedotnet would play nicely together - same issue as BlooberryPi3 above. Once imported, click any of the prefabs and its a constant jump back and forth between pointer and hourglass, like its constantly searching for any updates in the spriter file, which slows the editor down tremendously. Tested that on 3 different machines here and multiple unity versions, and they all do it. Mike at BrashMonkey 1 Quote
lucid Posted October 9, 2020 Report Posted October 9, 2020 @SquigglyFrog @BlooberryPi3 I'm not sure if this is still relevant for you, but I was able to fix both of those bugs (flickering pointer/hourglass when prefab is selected and import not working at all in later unity versions). If you'd like to use them while waiting for them to be merged into the main repository, you can download the package here: https://github.com/lucidspriter/SpriterDotNet/blob/develop/SpriterDotNet.Unity/SpriterDotNet.Unity.unitypackage Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.