Jump to content

SpriterDotNet.Unity


loodakrawa

Recommended Posts

  • 2 weeks later...
On 11/9/2015, 10:17:56, loodakrawa said:
SpriterDotNet.Unity

The Unity plugin for SpriterDotNet. Supports all Spriter features.

Documentation
The most up to date documentation can be found on the GitHub Repository.

hi there  loodakrawa!

I just downloaded it! awesome man! it worked smooth! but am wondering one thing, I can't seem to find the animations I had in my file in the animator, I did read your documentation but I didn't see anything about it. ( or I just didn't understand ) you mind explaining the process in depth regarding that?

thank you very much! 

Link to comment
Share on other sites

I encountered a few bugs when trying to import the plataformer pack:

-----------This shows up when i tried switching animations a character in the pack, with simply dragging the controller, running and pressing fire1,etc. ---------------

ArithmeticException: NAN
System.Math.Sign (Single value) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Math.cs:485)
SpriterDotNet.SpriterProcessor.ApplyParentTransform (SpriterDotNet.SpriterSpatial child, SpriterDotNet.SpriterSpatial parent) (at C:/dev/libs/SpriterDotNet/SpriterDotNet/SpriterProcessor.cs:438)
SpriterDotNet.SpriterProcessor.GetBoneInfos (SpriterDotNet.SpriterMainlineKey key, SpriterDotNet.SpriterAnimation animation, Single targetTime, SpriterDotNet.SpriterSpatial parentInfo) (at C:/dev/libs/SpriterDotNet/SpriterDotNet/SpriterProcessor.cs:265)
SpriterDotNet.SpriterProcessor.GetFrameData (SpriterDotNet.SpriterAnimation animation, Single targetTime, SpriterDotNet.SpriterSpatial parentInfo) (at C:/dev/libs/SpriterDotNet/SpriterDotNet/SpriterProcessor.cs:83)
SpriterDotNet.SpriterAnimator`2[TSprite,TSound].Animate (Single deltaTime) (at C:/dev/libs/SpriterDotNet/SpriterDotNet/SpriterAnimator.cs:142)
SpriterDotNetUnity.UnitySpriterAnimator.Animate (Single deltaTime) (at Assets/SpriterDotNet/UnitySpriterAnimator.cs:41)
SpriterDotNet.SpriterAnimator`2[TSprite,TSound].Step (Single deltaTime) (at C:/dev/libs/SpriterDotNet/SpriterDotNet/SpriterAnimator.cs:133)
SpriterDotNetUnity.SpriterDotNetBehaviour.Update () (at Assets/SpriterDotNet/SpriterDotNetBehaviour.cs:61)

 

 

------------These 2 show up when loading/adding the pack----------------
NullReferenceException: Object reference not set to an instance of an object
SpriterDotNetUnity.SpriterImporter.GetDrawablesCount (SpriterDotNet.SpriterAnimation animation, SpriterDotNet.SpriterMainlineKey key) (at Assets/SpriterDotNet/SpriterImporter.cs:281)
SpriterDotNetUnity.SpriterImporter.GetDrawablesCount (SpriterDotNet.SpriterAnimation animation) (at Assets/SpriterDotNet/SpriterImporter.cs:270)
SpriterDotNetUnity.SpriterImporter.GetDrawablesCount (SpriterDotNet.SpriterEntity entity) (at Assets/SpriterDotNet/SpriterImporter.cs:257)
SpriterDotNetUnity.SpriterImporter.CreateSprites (SpriterDotNet.SpriterEntity entity, SpriterDotNetUnity.ChildData cd, SpriterDotNet.Spriter spriter, UnityEngine.GameObject parent) (at Assets/SpriterDotNet/SpriterImporter.cs:118)
SpriterDotNetUnity.SpriterImporter.CreateSpriter (System.String path) (at Assets/SpriterDotNet/SpriterImporter.cs:76)
SpriterDotNetUnity.SpriterImporter.OnPostprocessAllAssets (System.String[] importedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPath) (at Assets/SpriterDotNet/SpriterImporter.cs:33)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets) (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:27)


NullReferenceException: Object reference not set to an instance of an object
SpriterDotNetUnity.SpriterDotNetBehaviour.Start () (at Assets/SpriterDotNet/SpriterDotNetBehaviour.cs:43)

-----------------------

 

It seems to work though.

Link to comment
Share on other sites

On 27/11/2015, 9:16:26, SkeletalRavenArts said:

hi there  loodakrawa!

I just downloaded it! awesome man! it worked smooth! but am wondering one thing, I can't seem to find the animations I had in my file in the animator, I did read your documentation but I didn't see anything about it. ( or I just didn't understand ) you mind explaining the process in depth regarding that?

thank you very much! 

Hi,

What exactly do you mean by "animations I had in my file in the animator"? Do you mean animations in the .scml file? The importer basically generates a prefab for every entity, and every entity should have all the animations as in the .scml file. If you need to check the imported data structure you can find a generated name.asset (where name is the same as in name.scml) which you can expand in the editor and take a look at all the data. Take a look at the attached screenshot.

Let me know if this gives you all the answers you need.

Cheers

snd_assets.PNG

Link to comment
Share on other sites

10 hours ago, Kiori said:

I encountered a few bugs when trying to import the plataformer pack:

-----------This shows up when i tried switching animations a character in the pack, with simply dragging the controller, running and pressing fire1,etc. ---------------

ArithmeticException: NAN
System.Math.Sign (Single value) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Math.cs:485)
SpriterDotNet.SpriterProcessor.ApplyParentTransform (SpriterDotNet.SpriterSpatial child, SpriterDotNet.SpriterSpatial parent) (at C:/dev/libs/SpriterDotNet/SpriterDotNet/SpriterProcessor.cs:438)
SpriterDotNet.SpriterProcessor.GetBoneInfos (SpriterDotNet.SpriterMainlineKey key, SpriterDotNet.SpriterAnimation animation, Single targetTime, SpriterDotNet.SpriterSpatial parentInfo) (at C:/dev/libs/SpriterDotNet/SpriterDotNet/SpriterProcessor.cs:265)
SpriterDotNet.SpriterProcessor.GetFrameData (SpriterDotNet.SpriterAnimation animation, Single targetTime, SpriterDotNet.SpriterSpatial parentInfo) (at C:/dev/libs/SpriterDotNet/SpriterDotNet/SpriterProcessor.cs:83)
SpriterDotNet.SpriterAnimator`2[TSprite,TSound].Animate (Single deltaTime) (at C:/dev/libs/SpriterDotNet/SpriterDotNet/SpriterAnimator.cs:142)
SpriterDotNetUnity.UnitySpriterAnimator.Animate (Single deltaTime) (at Assets/SpriterDotNet/UnitySpriterAnimator.cs:41)
SpriterDotNet.SpriterAnimator`2[TSprite,TSound].Step (Single deltaTime) (at C:/dev/libs/SpriterDotNet/SpriterDotNet/SpriterAnimator.cs:133)
SpriterDotNetUnity.SpriterDotNetBehaviour.Update () (at Assets/SpriterDotNet/SpriterDotNetBehaviour.cs:61)

 

 

------------These 2 show up when loading/adding the pack----------------
NullReferenceException: Object reference not set to an instance of an object
SpriterDotNetUnity.SpriterImporter.GetDrawablesCount (SpriterDotNet.SpriterAnimation animation, SpriterDotNet.SpriterMainlineKey key) (at Assets/SpriterDotNet/SpriterImporter.cs:281)
SpriterDotNetUnity.SpriterImporter.GetDrawablesCount (SpriterDotNet.SpriterAnimation animation) (at Assets/SpriterDotNet/SpriterImporter.cs:270)
SpriterDotNetUnity.SpriterImporter.GetDrawablesCount (SpriterDotNet.SpriterEntity entity) (at Assets/SpriterDotNet/SpriterImporter.cs:257)
SpriterDotNetUnity.SpriterImporter.CreateSprites (SpriterDotNet.SpriterEntity entity, SpriterDotNetUnity.ChildData cd, SpriterDotNet.Spriter spriter, UnityEngine.GameObject parent) (at Assets/SpriterDotNet/SpriterImporter.cs:118)
SpriterDotNetUnity.SpriterImporter.CreateSpriter (System.String path) (at Assets/SpriterDotNet/SpriterImporter.cs:76)
SpriterDotNetUnity.SpriterImporter.OnPostprocessAllAssets (System.String[] importedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPath) (at Assets/SpriterDotNet/SpriterImporter.cs:33)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets) (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:27)


NullReferenceException: Object reference not set to an instance of an object
SpriterDotNetUnity.SpriterDotNetBehaviour.Start () (at Assets/SpriterDotNet/SpriterDotNetBehaviour.cs:43)

-----------------------

 

It seems to work though.

Hey, can you provide more specific details about the exact .scml/entity/animation that cause these issues so I can investigate further? Thanks

Link to comment
Share on other sites

19 minutes ago, loodakrawa said:

Hi,

What exactly do you mean by "animations I had in my file in the animator"? Do you mean animations in the .scml file? The importer basically generates a prefab for every entity, and every entity should have all the animations as in the .scml file. If you need to check the imported data structure you can find a generated name.asset (where name is the same as in name.scml) which you can expand in the editor and take a look at all the data. Take a look at the attached screenshot.

Let me know if this gives you all the answers you need.

Cheers

snd_assets.PNG

Ouh thanks! 

alright! one more question, how can I check those animations and transition them, it keeps on looping the 1st animation.

 the previous Plugin which was Spriter2Unity had the option to go to the Animator Window and you will have all the Animations there, and from there you can connect them and control how the transition works. 
 


any similar option with SpriterdotnetUnity? 

Link to comment
Share on other sites

14 hours ago, SkeletalRavenArts said:

Ouh thanks! 

alright! one more question, how can I check those animations and transition them, it keeps on looping the 1st animation.

 the previous Plugin which was Spriter2Unity had the option to go to the Animator Window and you will have all the Animations there, and from there you can connect them and control how the transition works. 
 


any similar option with SpriterdotnetUnity? 

SpriterDotNet is a library that does all the work in pure C# code in order to support all Spriter features and be able to work with any .net frameworks/platforms. Unfortunately that means that it doesn't use platform specific things like Unity's animation system (which includes the Animator view).

The idea is to control the animations with SpriterAnimator  - you can take a look at the example provided.

That being said, Unity allows custom editors so I'll add the development of such a tool (something like the Animator view) to the project's long term goals.

Cheers

Link to comment
Share on other sites

9 minutes ago, loodakrawa said:

SpriterDotNet is a library that does all the work in pure C# code in order to support all Spriter features and be able to work with any .net frameworks/platforms. Unfortunately that means that it doesn't use platform specific things like Unity's animation system (which includes the Animator view).

The idea is to control the animations with SpriterAnimator  - you can take a look at the example provided.

That being said, Unity allows custom editors so I'll add the development of such a tool (something like the Animator view) to the project's long term goals.

Cheers

OUUUUUUUH! alright! thank you very much! and that was very helpful! and for sure that your plan in the future will be awesome!!!! thanks again! *thumbsup* you rock! 

Link to comment
Share on other sites

I'm getting errors trying to update an SCML file that has already been imported.
NullReferenceException: Object reference not set to an instance of an object
SpriterDotNet.SpriterProcessor.GetObjectInfo (SpriterDotNet.SpriterAnimation animation, System.String name)
SpriterDotNet.SpriterProcessor.AddVariableAndTagData (SpriterDotNet.SpriterAnimation animation, Single targetTime, SpriterDotNet.FrameMetadata metadata)
SpriterDotNet.SpriterProcessor.GetFrameMetadata (SpriterDotNet.SpriterAnimation animation, Single targetTime, Single deltaTime, SpriterDotNet.SpriterSpatial parentInfo)
SpriterDotNet.SpriterAnimator`2[TSprite,TSound].Animate (Single deltaTime)

 

Steps to reproduce:

  • Import the attached SCML file.
  • Allow SpriterDotNet to create Prefab "ArcherSCML"
  • Open SCML File, rename the entity to "ArcherSCML1", and save.
  • Allow SpriterDotNet to create a new prefab "ArcherSCML1"

It should now throw the above error anytime you try and drag either ArcherSCML or ArcherSCML1 into the scene.

 

archer.zip

Link to comment
Share on other sites

5 hours ago, esDotDev said:

I'm getting errors trying to update an SCML file that has already been imported.
NullReferenceException: Object reference not set to an instance of an object
SpriterDotNet.SpriterProcessor.GetObjectInfo (SpriterDotNet.SpriterAnimation animation, System.String name)
SpriterDotNet.SpriterProcessor.AddVariableAndTagData (SpriterDotNet.SpriterAnimation animation, Single targetTime, SpriterDotNet.FrameMetadata metadata)
SpriterDotNet.SpriterProcessor.GetFrameMetadata (SpriterDotNet.SpriterAnimation animation, Single targetTime, Single deltaTime, SpriterDotNet.SpriterSpatial parentInfo)
SpriterDotNet.SpriterAnimator`2[TSprite,TSound].Animate (Single deltaTime)

 

Steps to reproduce:

  • Import the attached SCML file.
  • Allow SpriterDotNet to create Prefab "ArcherSCML"
  • Open SCML File, rename the entity to "ArcherSCML1", and save.
  • Allow SpriterDotNet to create a new prefab "ArcherSCML1"

It should now throw the above error anytime you try and drag either ArcherSCML or ArcherSCML1 into the scene.

 

archer.zip

Hey, I can't access the attachment. I'm getting an error saying "The page you are trying to access is not available for your account." - might me a forum issue. Can you try to upload the file somewhere else?

Link to comment
Share on other sites

Also, one other small but pretty annoying issue, is that whenever the prefab is regenerated, the positioning and scaling info is reset anywhere in the project the prefab is references. 

I have an archer Game Object, with a nested Spriter Animation, positioned where I'd like him to be within his parent:
Archer
 --> ArcherSpriter (x = -1.78, y=3.16, scaleX: .85, scaleY: .85)

Everytime the SCML is reimported, the ArcherSpriter instance resets positioning to 0,0 and scale to 1,1. Any way those could be retained?

I also added a bit of functionality to UnitySpriterAnimator, in order to allow me to swap sprites at any time, in any animation:


Dictionary<string, Sprite> swappedSprites = new Dictionary<string, Sprite>();

public void UnswapSprite(string name) {
    if (swappedSprites.ContainsKey(name)) { swappedSprites.Remove(name); }
}
        
public void SwapSprite(string name, Sprite sprite) {
        swappedSprites[name] = sprite;
}

Sprite GetSprite(Sprite sprite) {
    if (swappedSprites.ContainsKey(sprite.name)) {
        return swappedSprites[sprite.name];
    }
    return sprite;
}

protected override void ApplySpriteTransform(Sprite sprite, SpriterObject info)
{
    ....
    renderer.sprite = GetSprite(sprite);
    ....
}

This allows me to do fun stuff, like make my character blink randomly, regardless of their animation state.

spriterAnimator.SwapSprite("eyesOpen", eyesClosedSprite);//Close eyes
//Wait 100ms
spriterAnimator.UnswapSprite("eyesOpen");//Open Eyes

Or, swap his hands randomly, to make it appear as if he's stumming a guitar, regardless of the current animation he's in. (our character can strum guitar while running, standing still, getting hit, etc, and we didn't want to have to bake that in to the animations themselves) 

//Inside a Coroutine
while(true){
    spriterAnimator.SwapSprite("chordHand_0", GetRandomChordSprite());
    spriterAnimator.SwapSprite("strumHand_0", GetRandomStrumSprite());
    yield return WaitForSeconds(tempo);
}

Doing it this way lets us change the tempo of the strumming to match the music, rather than having it tied to the animation speed.


This also allows you an easy way to do character maps, without having to define them in Spriter.

Link to comment
Share on other sites

Nice work! The plugin is very polished and ease of use.

However, I found an issue with the colliders:
After switching the animations, some sprites get their box collider mixed.
In my case, the arm collider became the weapon colllider, after switching animations.

Maybe I'm adding the colliders incorrectly (currently I'm adding one BoxCollider2D Component into each "Sprites" -> "Pivot" -> "Sprite" object).
Let me know if you need any more details for debugging (like the scml file, some screenshots...).

Link to comment
Share on other sites

Hi,

I am trying to intantiate multiple instances of the prefab generated through SpriterDotNet plugin for unity. 

This is my code :

public GameObject enemyPrefab; // The Prefab exported from Spriter goes here

public void Start ()
	{
		GameObject obj = Instantiate(enemyPrefab) as GameObject;
		obj.transform.parent = transform;

	}

The prefab is getting instantiated and also gets parented to the GameObject, however, i am getting an error while trying to access the UnitySpriterAnimator object 

Please find the code below :

public UnitySpriterAnimator animator;


//Written inside start
if (animator == null)
		{
			animator = gameObject.GetComponentInChildren<SpriterDotNetBehaviour>().Animator;
			animator.EventTriggered += e => Debug.Log("Event Triggered. Source: " + animator.CurrentAnimation.Name + ". Value: " + e);
		}

I got the following error while trying to use animator

NullReferenceException: Object reference not set to an instance of an object

It works fine if i get the reference for animator inside Update. Please let me know if this is an expected behavior. I am new to Unity and Spriter, I apologize in advance if my question is stupid :)

Link to comment
Share on other sites

@richard141289 According to Unity Script Reference:

Quote

It is better to use GetComponent with a Type instead of a string for performance reasons. Sometimes you might not be able to get to the type however, for example when trying to access a C# script from Javascript. In that case you can simply access the component by name instead of type.

http://docs.unity3d.com/ScriptReference/GameObject.GetComponent.html

So, instead of doing this:

animator = gameObject.GetComponentInChildren<SpriterDotNetBehaviour>().Animator;

Do this:

animator = (gameObject.GetComponentInChildren("SpriterDotNetBehaviour") as SpriterDotNetBehaviour).Animator;

 

Link to comment
Share on other sites

On 6/12/2015, 6:33:53, WormLice said:

Nice work! The plugin is very polished and ease of use.

However, I found an issue with the colliders:
After switching the animations, some sprites get their box collider mixed.
In my case, the arm collider became the weapon colllider, after switching animations.

Maybe I'm adding the colliders incorrectly (currently I'm adding one BoxCollider2D Component into each "Sprites" -> "Pivot" -> "Sprite" object).
Let me know if you need any more details for debugging (like the scml file, some screenshots...).

The colliders get added automatically under the "Metadata" -> "Boxes" object. However, I'm reusing collisions between animations and that could potentially cause problems. I'll look into it ASAP.

Link to comment
Share on other sites

9 hours ago, richard141289 said:

Hi,

I am trying to intantiate multiple instances of the prefab generated through SpriterDotNet plugin for unity. 

This is my code :


public GameObject enemyPrefab; // The Prefab exported from Spriter goes here

public void Start ()
	{
		GameObject obj = Instantiate(enemyPrefab) as GameObject;
		obj.transform.parent = transform;

	}

The prefab is getting instantiated and also gets parented to the GameObject, however, i am getting an error while trying to access the UnitySpriterAnimator object 

Please find the code below :


public UnitySpriterAnimator animator;


//Written inside start
if (animator == null)
		{
			animator = gameObject.GetComponentInChildren<SpriterDotNetBehaviour>().Animator;
			animator.EventTriggered += e => Debug.Log("Event Triggered. Source: " + animator.CurrentAnimation.Name + ". Value: " + e);
		}

I got the following error while trying to use animator


NullReferenceException: Object reference not set to an instance of an object

It works fine if i get the reference for animator inside Update. Please let me know if this is an expected behavior. I am new to Unity and Spriter, I apologize in advance if my question is stupid :)

This is probably due to the script execution order. If you want to do this init logic inside the Start method, jou just have to make sure the SpriterDotNetBehaviour runs before. Take a look here: http://docs.unity3d.com/Manual/class-ScriptExecution.html

Personally, I always do it in the Update method because I don't have to rely on project settings.

Link to comment
Share on other sites

13 hours ago, loodakrawa said:

The colliders get added automatically under the "Metadata" -> "Boxes" object. However, I'm reusing collisions between animations and that could potentially cause problems. I'll look into it ASAP.

There's only a GameObject called "Points" under "Metadata".

fLUQMwf.png

Link to comment
Share on other sites

5 hours ago, WormLice said:

There's only a GameObject called "Points" under "Metadata".

fLUQMwf.png

Just to check - does your Spriter file have collision boxes? Now I remembered you mentioned you were adding them manually. The thing is - this plugin uses a set of child objects and sprite renderers and reuses them between animations. If you manually attach colliders to these sprites they are going to change names between animations. However, if you add collision boxes in spriter they are going to be imported and created under Metadata. They're also being reused between animations but you should be able to differentiate them by name.

Let me know if this helps.

Link to comment
Share on other sites

 

38 minutes ago, loodakrawa said:

Just to check - does your Spriter file have collision boxes? Now I remembered you mentioned you were adding them manually. The thing is - this plugin uses a set of child objects and sprite renderers and reuses them between animations. If you manually attach colliders to these sprites they are going to change names between animations. However, if you add collision boxes in spriter they are going to be imported and created under Metadata. They're also being reused between animations but you should be able to differentiate them by name.

Let me know if this helps.


I'm using Spriter Essencials that doesn't support Collision Rectangles :|.
I believe that they can be calculated though.

Link to comment
Share on other sites

52 minutes ago, WormLice said:

 


I'm using Spriter Essencials that doesn't support Collision Rectangles :|.
I believe that they can be calculated though.

The problem is that everything under "Sprites" is essentially an implementation detail of the library so if you shouldn't rely on this. Additionally, the lib only "knows" about the collision boxes which are imported from spriter. What you potentially could do is creating collision boxes under another child of the main object and then attach a custom behaviour to the main object which updates the collision boxes based on the transforms of the objects under the "Sprites" child. Basically every frame iterate through the collision boxes, find the desired Sprite (probably by name) and apply the transforms to the collision box.

Link to comment
Share on other sites

On 12/8/2015 at 10:28 PM, loodakrawa said:

The problem is that everything under "Sprites" is essentially an implementation detail of the library so if you shouldn't rely on this. Additionally, the lib only "knows" about the collision boxes which are imported from spriter. What you potentially could do is creating collision boxes under another child of the main object and then attach a custom behaviour to the main object which updates the collision boxes based on the transforms of the objects under the "Sprites" child. Basically every frame iterate through the collision boxes, find the desired Sprite (probably by name) and apply the transforms to the collision box.

I'll will try it out and let you know how it goes.
Thanks for the help :D.

EDIT: There's probably a better way of doing this. When I added the BoxCollider2Ds to the Sprites they fit the Sprite size, position & rotation correctly. The only problem was when the Sprites switched for the Animation. Any ideas on how to fix that?

Link to comment
Share on other sites

On 29/11/2015 at 5:18 AM, loodakrawa said:

Hey, can you provide more specific details about the exact .scml/entity/animation that cause these issues so I can investigate further? Thanks

I believe what i used was :Spriter\Art Packs\Essentials\Adventure Platformer\PlatformerPack\Player.scml

Also, i'd like to point out that unity has some great new features for joints in 5.3:
http://blogs.unity3d.com/2015/12/08/unity-5-3-all-new-features-and-more-platforms/

 

They are physics components, but its worth noting.

Link to comment
Share on other sites

On 12/7/2015 at 8:59 AM, loodakrawa said:

This is probably due to the script execution order. If you want to do this init logic inside the Start method, jou just have to make sure the SpriterDotNetBehaviour runs before. Take a look here: http://docs.unity3d.com/Manual/class-ScriptExecution.html

Personally, I always do it in the Update method because I don't have to rely on project settings.

Thanks a lot loodakrawa, it works fine after changing the execution order. 

Excellent work on the plugin btw !!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...