Hi Im trying to respawn an object every time i collect it...This is what i have so far:
My problem is that Im trying to respawn these pick ups at different position in the map so my problem is in the function forceRespawn():
Any help would be greatly appreciated?
var SpawnPoint : GameObject;
var newobj : GameObject;
function Awake()
{
SpawnPoint.transform.position = transform.position;
}
function Update()
{
// Move the object to the right relative to the camera 1 unit/second.
transform.Translate(Time.deltaTime*8, 0, 0, Camera.main.transform);
var diffX = transform.position.x;
}
function OnTriggerEnter(otherGameObject : Collider)
{
if (otherGameObject.gameObject.name=="Player")
{
forceRespawn();
}
}
function forceRespawn()
{
transform.position.y = SpawnPoint.transform.position.y;
transform.position.z = SpawnPoint.transform.position.z;
transform.position.x = SpawnPoint.transform.position.x;
}