Hy there. First, sorry for my bad english, im not native.
Second: I few days ago i start playing around with Unity
Third: I want to stop my player when he hits a collider. I gave him the static variable “Player” in a other code. But in this code i can’t stop his movement. The code from "
function OnTriggerEnter2D (hitInfo : Collider2D) {
if (hitInfo.name == “Player”) {
Debug.Log (“Game Over”);" works fine. Here is my code:
#pragma strict
var "Player" : Rigidbody2D;
function OnTriggerEnter2D (hitInfo : Collider2D) {
if (hitInfo.name == "Player") {
Debug.Log ("Game Over");
rigidbody2D.velocity.x = 0;
rigidbody2D.velocity.y = 0;
}
}
I hope you can help me.