- Home /
Question by
King_JMK · Jan 19, 2015 at 03:10 PM ·
rigidbodytransformtransform.position
Rigid Body Wont transform
I AM Trying To Transfrom A Rigid Body position when it falls of a platform or hit the restart button Help me here is the code that i made
using UnityEngine;
using System.Collections;
public class FallDetact : MonoBehaviour {
GameObject player;
// Update is called once per frame
void start () {
GameObject.Find ("player");
}
void Update () {
if (player.transform.position.y <= -5); {
player.transform.position =new Vector3(0,2,0);
}
if(Input.GetKeyDown(KeyCode.R)){
player.transform.position =new Vector3(0,2,0);
}
}
}
but nothing happens.... help me
Comment
the script error is :object refrance not set to an instance of object ??? what does it mean and how to fix it ?
Answer by chariot · Jan 19, 2015 at 03:14 PM
Try to use
void Start () {
player = GameObject.FindGameObjectWithTag("Player");
}
And add tag to player of course