Thursday, 12 July 2012

Unity Teleport Code

This is a little piece of code i knocked up to handle respawns and various semi instance systems.

Shove it in a javascript file, hook it to a collider with the "is trigger" checkbox selected.  Change the cam to the character camera, and the destination to an empty gameobject placed where you want the character to go.  And done, your character should enter the collider, and exit at the destination point.

#pragma strict var destination : Transform; var cam : Camera; function Start () { } function Update () { } function OnTriggerEnter () { Teleport(); } function Teleport(){ cam.transform.position = destination.position; }

The system is being used for Frozen Skies.  I have been making videos on it for some time now.  Frozen Skies is a comglomerate of my better ideas, constantly refined into a winter survival game, where anything may kill you, and in some areas, you might accidentally kill yourself.

I am probably a few weeks away from doing a limited public test, before releasing it on the world as a very basic alpha.  This past week i have just been getting a few things straight, building a world on which people can play and implementing a save system coded by this guy:
The save and load isn't fully implemented, and won't be for some time, but players can save their character progress and inventories, and name their saves something meaningful.

As for other features, i have a day/night system, plantable trees that then grow over time, a crafting system that takes into account the players proximity to workbench objects and their upgrade level, the players inventory and the item the player has activated.  The player can build structures, from gates and fences, to nuclear missile silos.

So, that's the lot for this week. Enjoy!

No comments:

Post a Comment