Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/04/2015 in all areas

  1. esDotDev

    SpriterDotNet.Unity

    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.
    1 point
×
×
  • Create New...