SiscoArtz

void Awake(){

SkelAnim = GetComponent<SkeletonAnimation>();

SkelAnim.state.SetAnimation(0,walk,true);

SkelAnim.skeleton.SetSkin("footballthug_11");

}

so I would like this line to// SkelAnim.skeleton.SetSkin("footballthug_11");

to call a random skin between footballthug_1 footballthug_60





Thanks for any help
SiscoArtz
  • Posts: 6

Harald

This will work with standard C# string+integer concatenation, so
System.Random randomNumberGenerator = new System.Random();
...
int randomSkinNumber = randomNumberGenerator.Next(1, 61); // creates a number between 1 and 60
string skinName = "footballthug_" + randomSkinNumber; // or if you prefer: = String.Concat("footballthug_", randomSkinNumber);
SkelAnim.skeleton.SetSkin(skinName );
In general I would advise to search the web for general C# programming questions, this will yield results faster.
User avatar
Harald

Harri
  • Posts: 953

SiscoArtz

Thank you, Harold your a total LEGEND! I'm finding it very hard to get the answers I need from other sources as they tend not to discuss implementing Spine.

Thank you again!
SiscoArtz
  • Posts: 6

badlogic

This is less of a Spine related question and more of a C# related question though. I suggest you also give books/tutorials for C# a look. A better grasp of the programming language you use will make it easier for you to solve issues like this in the future.
User avatar
badlogic

Mario
  • Posts: 2013

Harald

Thanks for your kind reply SiscoArtz! :)

Actually @badlogic is absolutely right - it is very (very very) important and helpful to learn the basics of at least one programming language since you will have all the tools in your hand then. Even if that takes some time, you will get back every minute invested multiple times. It is even less relevant which language that is, be it Java, C# or even C++ (though I would not recommend C++ in your case) - the fundamentals are the same.
User avatar
Harald

Harri
  • Posts: 953

SiscoArtz

I see, I got that wrong, I thought it was certain code only for spine I needed, it all makes sense now, I will carry on and go back to my bootcamp lessons in C sharp, thanks for helping me out
SiscoArtz
  • Posts: 6


Return to Unity