- Home /
Teleportation script causing crash?
For some reason this script is causing my editor to crash. No idea why.
using UnityEngine;
using System.Collections;
public class killerlocationboop : MonoBehaviour {
public Vector3 newlocation=new Vector3();
Vector3 startlocation;
void Start(){
startlocation = rigidbody.position;
}
// Update is called once per frame
void Update () {
if (0 <=Time.timeSinceLevelLoad % 10 && Time.timeSinceLevelLoad % 10 <= 4) {
rigidbody.position = newlocation;
} else {
rigidbody.position = startlocation;
}
}
}
Comment
Best Answer
Answer by Xarathorn · Jan 27, 2014 at 01:24 AM
Okay I figured it out. Just replace all the rigidbody
s with transform
s.
Answer by gogott · Jan 27, 2014 at 01:24 AM
try:
public Vector3 newlocation = Vector3.zero;
instead of:
public Vector3 newlocation = new Vector3();
No, you're supposed to be able to enter the values you want. Vector3() allows you to do this in the editor window.
Your answer
![](https://koobas.hobune.stream/wayback/20220613131534im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Only Teleports Player Every Once in While 2 Answers
Making The Hole In A Golf Game 1 Answer
during build object moves different position than editor(vr) 1 Answer