Reset Object

Is there a more stream lined way of doing an object reset or state restore ?

I am tired of writing the original position / original scale / original rotation in the onstart, and having a custom script on hundreds of objects just to reset them as they were when the level started.

Does anyone have a better strategy or is this the way to go ? It would be nice if the full transform had a setter for the transform.

At least then its 1 struct as opposed to 3 to have to set

You can use Application.LoadLevel() to reload the scene in its original state.

If you are ok with reloading the level just do what Ben 12 said.

Otherwise, could just have 3 vec3s and store their own default positions.

private Vector3 defPos;
private Vector3 defRot;
private Vector3 defScale;

void Start()
{
  defPos = transform.position;
  defRot = transform.localRotation;
  defScale = transform.localScale;
}

public void Reset()
{
  //Reset them back
}

That’s the most simplest way imo.

Edit: Assuming if they are already placed in the world.

need to know that too T_T

Just putting this out there-

public static void Apply(this Transform target, Transform original)
{
    target.parent = original.parent.
    target.position = original.position;
    target.localScale = original.localScale;
    target.rotation = original.rotation;
}

C# only, unless there’s some way of doing this in JS. Basically you call it using

transform.Apply(some other transform);

and it’ll set all of your transform’s values to that of the other one.