Well if you deal with Unity all day you probably faced this situation: “This object looks good here, I want to copy and paste all these other objects to that position”, and I lost count how many times I saw level designers writing on a paper or using Text Edit or (Note Pad) to type on each object the saved position.
I started thinking about develop a tool to solve that problem when I saw NGUI reseting options on transform panel. Then I though well it should be nice with I can copy and paste on the same place, but I keep the idea stored.
Before we at Secret Weapon used another editor tool which you have to click on Editor tab on top of screen and then again to paste desired transform option. All team complain about that, but as always I have thousands things to do and keep the solution for another time.
One day the level designer came to me and said: “Why Unity doesn’t make an easy way to copy positions, rotations and scales?” I answered him: “Today it’s your luck day”. Few hours later I came up with that tool for him to use, he was doing a exhaustive level construction scene in Unity. You can image his happiness 🙂
Easily reset position, scale and rotation with one click, by clicking on POS, ROT, or SCALE.
Also copy and paste transform with one click, by clicking on C or P of respective type.
Pick one of our secret weapons that we use everyday!
Hey, today I’ll show our newest game, called Fire for your Life, a twin brother of already released Race for your Life. As you may know 🙂 or not yet :(, it’s a tank battle game with retro style, multiplayer and cross platform. More specifically I’ll demonstrate its game modes, which are five:
Death match – last player in the map wins.
Capture the flag – player with more captured flags wins or the last survival wins.
Domination – player with more bases wins at end time or the last survival wins.
Protect base – each player has a base, if it is destroyed his tank dies, the last survival wins.
One shot one kill – each shot is mortal, the last survival wins.
So after that said, you noticed that each mode share one specific rule, the last tank is the winner. The point is that usually in Unity, we programmers blind ourselves in some basic object orientated programming. For example this is a good case to use a base class with common properties and functionalities.
public class GMBase : MonoBehaviour, IGameMode
protected bool finished;
public virtual void StartGame()
finished = false;
//your start logic
public virtual void CheckEndGame()
//your check end game logic, could be time, players life, etc
public virtual void FinishGame()
//call managers to handle end game, display game over, etc
finished = true;
Also provide an interface that forces classes to implement game mode functions.
public interface IGameMode
/// Called by game controller when game is initiated
/// Called by game controller on a loop to check end game
/// When game really ended, it call Game Controller
Later we can create another script class that handle Domination game mode logic. Note that we don’t need to write all code checking tank deaths and so on, keeping our code clean and lean.
public class GMDomination : GMBase
private float timer;
public override void StartGame()
timer = 0;
timer += Time.deltaTime;
//Check Winner after X seconds passed
Domination Game Mode Class
So next time implementing things like this I hope you can use this approach to help your game development. Here is dev video showing it in action.