Hello everyone,!
here is a small demonstation of my problem
http://pn.dyna-studios.com/TA-Problemdemo/WebPlayer.html
If you get to this spear and press E, the weapon is parented to an empty gameObject in the right hand. Then the Weapon follows the Hand perfectly, except the framerate drops to the ground. I’ve been working for days on this issue and I have no idea why this is the case.
The Weapon has no scripts attached to it. I have also made a Screenshot at Runtime:
Here is my “ItemPickup” Script; it’s attached to the Player:
var clone : GameObject;
var item_name;
var WeaponHand : GameObject;
var WeaponHandParent : GameObject;
var showGUI = false;
WeaponHand = GameObject.FindWithTag("weaponmount"); //The Tag of The Empty that's parented to the right Hand
function OnTriggerEnter (other : Collider) {
if (other.gameObject.tag == "weapon"){
showGUI = true; //activate Weapon Pickup Text on collision
}
}
function OnTriggerStay (other : Collider) {
if (other.gameObject.tag == "weapon"){
Debug.Log("WaffenKollision!"); //Collision
item_name = other.gameObject.name;
Debug.Log("item_name: " + item_name); // Get the Items Name
if (Input.GetKeyDown ("e")){
clone = GameObject.Find(item_name); // Get the Item we are colliding with
Debug.Log("clone: " + clone);
clone.transform.parent = WeaponHand.transform;
clone.transform.position = WeaponHand.transform.position;
clone.transform.rotation = WeaponHand.transform.rotation;
Debug.Log("Parented !");
}
}
}
function OnTriggerExit (other : Collider) {
if (other.gameObject.tag == "weapon"){
showGUI = false; //deactivate Weapon Pickup Text
}
}
function OnGUI(){
if (showGUI){
GUI.Label (Rect (500,500,1000,1000), "[E] Waffe aufnehmen"); //"Press E to Pickup the Weapon"
}
}
I hope somebody has an idea of how to solve this, this drives me crazy.
Greetings from Germany