can someone tell me the difference between this
Ragdoll R = (Instantiate (ragdoll, transform.position, transform.rotation) as GameObject).GetComponent();
R.CopyPose (transform);
Destroy (this.gameObject);
As opposed to just doing something like the latter. The component is still being accessed so what's the difference?
using UnityEngine;
using System.Collections;
public class Entity : MonoBehaviour
{
public float health;
public GameObject ragdoll;
public Ragdoll R;
public void Star ()
{
R = GetComponent();
}
public void TakeDamage(float dmg)
{
health -= dmg;
if (health <= 0)
{
Die();
}
}
public void Die()
{
ragdoll = Instantiate (ragdoll, transform.position, transform.rotation) as GameObject;
R.CopyPose (transform);
Destroy (this.gameObject);
}
↧