I can’t detach the player from helicopter upon collision.
Look at the script…
I don’t know what I’m doing wrong.
everything seems to be fine!
using UnityEngine;
using System.Collections;
public class Helic : MonoBehaviour {
public BoxCollider col;
public Animation anim;
public string animName;
public float speedanim;
public Transform player;
//bool detachChild = true;
void Start(){
player.GetComponent<MoveController> ().enabled = false;
player.GetComponent<Rigidbody> ().mass = 0f;
Update ();
}
void Update(){
anim [animName].speed = speedanim;
anim [animName].wrapMode = WrapMode.Once;
anim.Play (animName);
if (col.gameObject.tag == "ground") {
player.transform.parent = null;
player.GetComponent<MoveController> ().enabled = true;
player.GetComponent<Rigidbody> ().mass = 10f;
anim.Stop ();
Destroy (this.gameObject);
}
}
}