How do I change a sprite in 2D Toolkit ....

Im somewhat new to scripting, but I cant figure out how to change the sprite while I move in different directions.

I have the movement script set up, but the sprite is just facing downwards the entire time.
Im using 2D toolkit, so I have my sprite collection with all 4 directions.

I just need to know how to change the sprite to the specific direction that I am moving in when I press the movement keys.

So in Unityscript. You’ll have some variables like this …

var dogImage : tk2dSprite;
var catImage : tk2dSprite;

Do you correctly know how to “hook those up” in the editor by dragging, right? If not unityGems.com or ask a separate question.

Essentially, to set the image just do this:

dogImage.SetSprite( "collie" );
dogImage.SetSprite( "dane" );
dogImage.SetSprite( "labrador" );

You can see it right there in the doco:

http://www.2dtoolkit.com/docs/2.20/html/classtk2d_base_sprite.html

note that if you want to change the collection, it’s like this…

dogImage.SetSprite( colPrimary, colPrimary.GetSpriteIdByName("eBOXC") );

(If you’re just starting out, you likely only have one big collection, so ignore this concept.)

ALSO - there is an excellent 2dTK forum where you will get fast answers.

As you are new to this site please TICK any helpful answer here as only you can close out questions.

Regarding pressing a key I urge you to first search on here, as there are literally 100s of great questions about it on here.

please simply type “direction keys” up the top and click search.

Or, click on this link:

https://www.google.com/search?q=answers.unity3d.com+direction+key

ok?