#pragma strict
var gameController : GameController;
var rb: Rigidbody2D;
function Start () {
rb = gameObject.GetComponent (Rigidbody2D);
var gameControllerObject : GameObject = GameObject.FindWithTag ("GameController");
if (gameControllerObject != null)
{
gameController = gameControllerObject.GetComponent (GameController);
}
if (gameController == null)
{
Debug.Log ("Cannot find 'GameController' script");
}
};
function Update () {
};
function OnTriggerEnter2D(other: Collider2D)
{
if (other.gameObject.CompareTag ("Player"))
{
SpawnLoop();
gameController.AddScore();
Debug.Log("A Phone has made contact with the Player");
}
if (other.gameObject.CompareTag ("Floor"))
{
SpawnLoop();
Debug.Log("A Phone has made contact with the Floor");
}
}
;
function SpawnLoop()
{
transform.position = Vector2(transform.position.x, 6);
rb.isKinematic = false;
};
The 2D rigidbody isn’t being set to is kinematic.
What am I doing wrong?