Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Ragdoll issues in code [SOLVED]

Discussion in 'Scripting' started by Troas, Jun 17, 2014.

  1. Troas

    Troas

    Joined:
    Jan 26, 2013
    Posts:
    157
    So I'm trying to create a code that instantiates ragdoll when the player reaches 0 health

    Code (CSharp):
    1. public GameObject ragdoll
    2.  
    3. public void Die(){
    4.         Ragdoll r = (Instantiate (ragdoll, transform.position, transform.rotation)as GameObject).GetComponent<Ragdoll> ();
    5.         Destroy (this.gameObject);
    6.     }
    The health code works, I'm trying to figure out why this bit tells me that "Ragdoll" doesn't exist in its current context. It should show up on my player control script as a new component value I can set but it doesn't. The tutorial I'm following does it this way and it works perfectly fine, no other variables were defined other than a health variable.


    EDIT: Solved, the tutorial never showed the need for a Ragdoll sript, eventually figured that out and coded for it.
     
    Last edited: Jun 17, 2014
  2. ElvisAlistar

    ElvisAlistar

    Unity Technologies

    Joined:
    Oct 2, 2013
    Posts:
    226
    Is that script compiling? You're missing a ; after
    Code (csharp):
    1. public GameObject ragdoll
     
  3. Troas

    Troas

    Joined:
    Jan 26, 2013
    Posts:
    157
    Yea I had that in the code just forgot to type it here.

    Once I figured out the guy in the tutorial had a script called "Ragdoll" but never actually showed making it I went ahead and made one and it ended up working.

    Thanks for the help though!