# Custom coin asset

Let's say you have a model, that has been prepared for Torque, and some textures and now you want to use that instead of the boring torus primitive.

We will do a step-by step of how to import these files first download this zip file:

{% file src="<https://1474639700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXe4ekLqNACmy9Udfvs4k%2Fuploads%2FaBzO58wSFjavnhbVyisa%2FkorkCoin.zip?alt=media&token=6708c1dc-3861-49e1-ae30-ebd646300e17>" %}

And extract it into `data/CoinCollection/objects/korkCoin` such that you get the following four files inside that directory:

* data/CoinCollection/objects/korkCoin
  * korkCoin.fbx
  * korkCoin\_albedo.png
  * korkCoin\_n.png
  * korkCoin\_orm.png

Then open up the World Editor and find the Asset Browser:\
![](https://1474639700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXe4ekLqNACmy9Udfvs4k%2Fuploads%2FTwMptBxv4RLAdk8wZxdT%2Fimage.png?alt=media\&token=ab909da9-ba8a-4a4a-b4f6-5966170c7875)\
Navigate to `data/CoinCollection/objects/korkCoin` and click on the exclamation mark:\
![](https://1474639700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXe4ekLqNACmy9Udfvs4k%2Fuploads%2FpHutV4e81N5lfIsKrXAu%2Fimage.png?alt=media\&token=854d56b4-474e-402b-9ef5-9ae92fe242e7)

This will load all the files in as separate assets:\
![](https://1474639700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXe4ekLqNACmy9Udfvs4k%2Fuploads%2Fpp8sehyvQYoA8RlAURfs%2Fimage.png?alt=media\&token=6aa24203-6b46-416d-a37b-6a5827ff751b)

![](https://1474639700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXe4ekLqNACmy9Udfvs4k%2Fuploads%2FmO1ldqbdTmiGMfa0qTAk%2Fimage.png?alt=media\&token=49f61876-7c32-4d70-9678-3f1fb9f51826)\
Now we need to tie them together, right-click the material asset and click on `Edit Asset`<br>

In the Material Editor, set the `Diffuse Map` to the albedo image asset, the `Normal Map` to the normal image asset and the `ORM Map` to the orm image asset.\
![](https://1474639700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXe4ekLqNACmy9Udfvs4k%2Fuploads%2FaiLtfGxk55kpPuo3nj3W%2Fimage.png?alt=media\&token=06a7ee6b-9fb0-442b-ba09-aaf998cfe24b)

Then click the save button, and confirm that everything looks right by dragging a "korkCoin\_shape" asset into the scene.

Finally, open up `data/CoinCollection/datablocks/coin.tscript` and change the `ShapeAsset` of your Coin datablock to this newly imported shape:

```csharp
datablock StaticShapeData( Coin ) {
    ShapeAsset = "CoinCollection:korkCoin_shape";
    category = "CoinCollectionObjects";
};
```

### Playing a simple animation

The `korkCoin.fbx` file has a simple animation built in. It simply rotates the coin around once. Let's play this on our coins. The animation is called `korkCoin|ambient`.

First open up `data/CoinCollection/objects/korkCoin/korkCoin.tscript` and add the following function to the end of the file:

```csharp
function korkCoinfbx::onLoad(%this)
{
    %this.setSequenceCyclic("korkCoin|ambient", "1");
}
```

This will make sure that our animation plays on a loop. \
Now we need to play this animation on all coins that are spawned, we can do that on the `onAdd` callback for each `Coin` in `data/CoinCollection/server/coin.tscript`:

```csharp
function Coin::onAdd(%this, %obj) {
    %obj.playThread( 0, "korkCoin|ambient" );
}
```

Remember here that `Coin` is the datablock, so the second parameter `%obj` is the actual Coin instance itself.&#x20;
