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:
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 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:
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:
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
:
Remember here that Coin
is the datablock, so the second parameter %obj
is the actual Coin instance itself.
Last updated