I’m attempting to program a script so that when my player enters a cube, he is teleported to the map spawnpoint. Everything works fine when I have a debug text in the code, but the moment I use rigidbody.position and touch the cube, the game freezes. I’m using Unity 5.1.2f1
using UnityEngine;
using System.Collections;
public class DeathManager : MonoBehaviour {
private Rigidbody rb;
//Start the code
void Start () {
rb = GetComponent <Rigidbody> ();
}
//Detect player entering void
void OnTriggerEnter (Collider other) {
if (other.tag == "Void") {
Die();
}
}
//Move player to save point
public void Die() {
if (Savestate.active.progress == 1) {
rb.position = new Vector3(10, 51, 10);
}
}
}
Edit Overview #1: Fixed code to be the actual script, added unity version