void OnTriggerEnter(Collider collision) { if (collision.tag == "pot") { GetComponent <Rigidbody>().isKinematic = true; player = GameObject.FindGameObjectWithTag("Player").GetComponent <playerCon>(); collision.transform.parent = transform; player.grabedenemy = collision.gameObject; player.reverse = -1; player.fasterAtStart = -.5f; collision.gameObject.GetComponent <Rigidbody>().isKinematic = true; collision.tag = "item"; } if (collision.tag == "enemy") { GetComponent <Rigidbody>().isKinematic = true; player = GameObject.FindGameObjectWithTag("Player").GetComponent <playerCon>(); collision.transform.parent = transform; player.grabedenemy = collision.gameObject; player.reverse = -1; player.fasterAtStart = -.5f; collision.gameObject.GetComponent <Rigidbody>().isKinematic = true; collision.GetComponent <Animator>().SetBool("grabbed", true); collision.gameObject.transform.LookAt(player.transform, Vector3.up); collision.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; collision.GetComponent <zombieEnemy>().trueonRagdoll(); collision.GetComponent <zombieEnemy>().noGravity(); collision.GetComponent <zombieEnemy>().ragdolled = true; collision.GetComponent <zombieEnemy>().centerOfMass.GetComponent <Rigidbody>().isKinematic = true; collision.tag = "item"; } if (collision.tag == "robot") { GetComponent <Rigidbody>().isKinematic = true; player = GameObject.FindGameObjectWithTag("Player").GetComponent <playerCon>(); collision.transform.parent = transform; player.grabedenemy = collision.gameObject; player.reverse = -1; player.fasterAtStart = -.5f; collision.gameObject.GetComponent <Rigidbody>().isKinematic = true; collision.gameObject.transform.LookAt(player.transform, Vector3.up); collision.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; collision.GetComponent <robot>().trueonRagdoll(); collision.GetComponent <Rigidbody>().useGravity = false; collision.GetComponent <robot>().ragdolled = true; collision.GetComponent <robot>().breakcube(); collision.GetComponent <robot>().centerofmass.GetComponent <Rigidbody>().isKinematic = true; collision.GetComponent <robot>().noGravity(); collision.tag = "itemr"; } }
// Start is called before the first frame update void Start() { dataSaver = GetComponent <DataSaver>(); player1Con = player1.GetComponent <playerCon>(); player2Con = player1.GetComponent <playerCon>(); Material material = loadObject.GetComponent <MeshRenderer>().material; material.SetFloat("_ScrollSpeed", loadScroolSpeed); rocks = new List <GameObject>(); spwan = false; timerc = timer.GetComponent <TimerController>(); counterc = counter.GetComponent <CountController>(); }
// Start is called before the first frame update void Start() { canvas = GetComponent <Canvas>(); player1Life = new List <GameObject>(); player2Life = new List <GameObject>(); player1Con = player1.GetComponent <playerCon>(); player2Con = player2.GetComponent <playerCon>(); tmpP1HP = player1Con.HP; tmpP2HP = player2Con.HP; for (int i = 0; i < tmpP1HP; i++) { player1Life.Add(Instantiate(player1Prefab, new Vector3(40.0f * (float)(i + 1), (float)Screen.height - 20.0f, 0.0f), Quaternion.identity, this.gameObject.transform)); player2Life.Add(Instantiate(player2Prefab, new Vector3((float)Screen.width - 40.0f * (float)(i + 1), (float)Screen.height - 20.0f, 0.0f), Quaternion.identity, this.gameObject.transform)); } }