Hi Chris,
Is it possible to have a spine player with 8 separate GameObjects each with their own SkeletonAnimation, and then handle disabling/enabling them as-needed (based on the direction my character is facing)? I want to swap skins in and out and as my player has 8 directions I will need to swap in and out 8 different children spine skeletons. If that makes sense?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
The Spine Integration on the AC wiki allows for this.
We are already discussing this in your other thread.
Hi Chris,
I am trying to use a custom action script to change the skin. But I am getting an error:
Assets/Sleepytime Village/Scripts/CustomActions/ChangeSkinAction.cs(29,13): error CS0246: The type or namespace name 'SkeletonAnimator' could not be found (are you missing a using directive or an assembly reference?)
Here is my code, can you help at all?
in fact, i think this code, but i would need this as a custom script if possible? Ignore code above:
In what way do you want to customise it? The ChangeSkin method is public - you can call it from AC Actions.
Update, so I have made it into a custom action successfully, but get two errors:
The Spine GameObject is missing once the scene is stopped.
and
Plus, it isn't changing the skin, and I wonder if it is because the skin is actually Clothes/(skinname) - see screenshots.
https://www.dropbox.com/sh/r7x1oxds8jm3k16/AADoYzE8dSn34odF81TBopE0a?dl=0
Updated code below:
If your Action references a Player prefab that's spawned in at runtime, you need to access the Player with KickStarter.player - any reference made to the GameObject itself won't work at runtime.
e.g.:
This is not an AC issue - the SkinExample script demonstrates how to change a Spine skin.
updated code to what you updated but getting this error:
Assets/Sleepytime Village/Scripts/CustomActions/ChangeSkinAction.cs(3,1): error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations
Plus, SpineExample only works on player instance in scene, and in trying it out the SkinExample script (empty game opbject in scene, dragging skeleton instance in from scene) it is removed from the scene on play instantly.
Be sure to replace all code in the script with the code above.
Can you help me understand how to incorporate the SpineExample script into a custom action script so I can insert the skin name into the action for the player prefab spineGameObject like in ChangeSkinAction (that currently seems to not do anything )
The Action and SkinExample script are doing two different things.
The SkinExample calls SetSkin to change the skin name, different to your Action which calls initialSkinName.
Adapt SkinExample to behave the way you want it to before attempting to convert it into an Action.
Problem is I cannot get the SkinExample to work or do anything currently, See video and PDF detailing everything.
PDF:
https://www.dropbox.com/s/y0krbbgslmcea18/Switching Skins.pdf?dl=0
Video:
https://www.dropbox.com/s/q99zv8op15r7ptk/SpineSkinHeadache.mov?dl=0
Thanks Chris!
The SkinExample script is unrelated to AC. It will not change the skin automatically, however - it's a case of calling its ChangeSkin function manually.
Ok, no probs, tried that and got an error, I appreciate it is not related to AC, but any further help you can spare would be greatly received :
Uncomment the Debug.Log in the script - that'll help reveal the issue.
only thing revealed in Console is the same error:
NullReferenceException: Object reference not set to an instance of an object
SkinExample.ChangeSkin () (at Assets/Sleepytime Village/Scripts/SkinExample.cs:42)
UnityEngine.Events.InvokableCall.Invoke () (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:180)
UnityEngine.Events.UnityEvent.Invoke () (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent/UnityEvent_0.cs:58)
AC.ActionEvent.Run () (at Assets/AdventureCreator/Scripts/Actions/ActionEvent.cs:39)
AC.ActionList+d__41.MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:429)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:379)
AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:571)
AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:530)
AC.d__41:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:494)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:379)
AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:571)
AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:530)
AC.d__41:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:494)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:379)
AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:571)
AC.ActionList:EndActionParallel(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:653)
AC.d__41:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:490)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:379)
AC.ActionList:BeginActionList(Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:346)
AC.ActionList:Interact(Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:247)
AC.ActionList:Interact() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:210)
AC.SceneSettings:PlayStartCutscene() (at Assets/AdventureCreator/Scripts/Game engine/SceneSettings.cs:346)
AC.SceneSettings:OnStart() (at Assets/AdventureCreator/Scripts/Game engine/SceneSettings.cs:110)
AC.SaveSystem:InitAfterLoad() (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:692)
AC.MultiSceneChecker:Start() (at Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:62)
I just need to be able to access the SkeletonAnimation, initial Skin dropdown choices in a custom action script so at the start of a scene i can set player prefab to be Clothes/Suit eg or Clothes/UnTuck eg - these work if i manually choose the dropdown on the Player prefab, but I want to access on scene start for my prefab.
It's unrelated to AC. Leave the Player prefab in the scene so that it's not being spawned in at runtime, and focus on getting the SkinExample script working. Once you've debugged it, revisit this topic and we can see about converting it into an action.