I am working on a simple game where the player should come back to the original position to end the game. What kind of scripting can I do for making the engine memorize this initial position?
Use a variable to capture the original Transform of the player when the object is first used.
c#
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
private Transform originalSpawnTransform;
void Start() {
originalSpawnTransform = transform;
}
}
UnityScript
private var originalSpawnTransform: Transform;
function Start()
{
originalSpawnTransform = transform;
}
now when you’d like, use the originalSpawnTransform to place the gameobject transform from where they first spawned. This is providing you don’t have anything else interesting going on.