public GameObject LiaoKuai_Assm;
public void onClick_LiaoKuai_Assm()
{
Quaternion q = Quaternion.AngleAxis(90, Vector3.right);
Instantiate(LiaoKuai_Assm, new Vector3((float)0.595799983, (float)0.885534179, (float)0.409999996), q);
}
private void OnCollisionEnter(Collision collision)
{
collision.collider.transform.parent = this.transform;
collision.collider.transform.GetComponent<Rigidbody>().isKinematic = true;
}
I generated a prefab. When this prefab collides with a gameobject, I want to change the parent of this prefab to this gameobject, but
collision. collider. transform. parent=this. transform; Not effective.
Collision. collider. transform. GetComponent(). isKinematic=true; It can be executed normally.