Question by
kubstoff · Apr 10, 2017 at 12:40 PM ·
instantiatedestroycreate
toggling ragdoll as new object
so i would like to destroy my player object on collision with saw for example and create ragdoll object on its position . how do i do that???
here's my code
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class checkifdead : MonoBehaviour {
public GameObject object_to_destroy;
public GameObject ragdoll_object_to_create;
public GameObject obj_to_hit;
// Use this for initialization
void Start () {
}
private void OnCollisionEnter2D(Collision2D hit)
{
if (hit.gameObject.name == obj_to_hit.name)
{
instantiate(object_to_create,object_to_destroy);
}
}
// Update is called once per frame
void Update () {
Destroy(object_to_destroy, 0f);
}
}
Comment