Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

How Do I Set A 2D Rigidbidy as isKinematic = true through a script?

$
0
0
#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?

Viewing all articles
Browse latest Browse all 1875

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>