Ok, so i have my ragdoll being instantiated at the player rotation and position when it collides with some electricity that comes out of my enemy, but when i do so the ragdoll goes crazy. goes into the floor and flails around. I am postion two images, one that shows the ragdoll components and one that shows it ones it’s instantiated.
[833-Screen+shot+2012-05-04+at+21.39.21.png|833]
I’ll show you the code as well
#pragma strict
var enableGUI : boolean = false;
static var beenKilled : boolean = false;
private var respawnPoint : Transform;
private var player : Transform;
var ragDoll : Transform;
var playerReplacement : Transform;
function Start () {
respawnPoint = GameObject.FindWithTag("respawnPoint").transform;
player = GameObject.FindWithTag("Player").transform;
yield WaitForSeconds(4);
Destroy(this.gameObject);
}
function OnTriggerEnter (hitPlayer : Collider) {
if(hitPlayer.gameObject.tag == "Player") {
var deadBody = Instantiate(ragDoll, player.transform.position, player.transform.rotation);
Debug.Log("ragdoll instantiated");
Destroy(hitPlayer.gameObject);
yield WaitForSeconds(1);
enableGUI = true;
beenKilled = true;
}
}
function OnGUI () {
if(enableGUI == true) {
Time.timeScale = 0;
GUILayout.BeginArea( Rect(Screen.width/2, Screen.height/2, 200, 200) );
GUILayout.BeginVertical("Box");
GUILayout.Label("You Got Killed");
GUILayout.Space(10);
if(GUILayout.Button("Continue")) {
if(beenKilled == true) {
enableGUI = false;
Time.timeScale = 1;
Instantiate(playerReplacement, respawnPoint.transform.position, respawnPoint.transform.rotation);
Destroy(gameObject.FindWithTag("ragdoll"));
Destroy(this.gameObject);
}
}
if(GUILayout.Button("Go To Main Menu")) {
Application.LoadLevel("startScreen");
Time.timeScale = 1;
}
GUILayout.EndVertical();
GUILayout.EndArea();
}
}