void OnCollisionEnter(Collision col) { NetworkLiveManager liveManager = col.gameObject.GetComponent <NetworkLiveManager> (); //Debug.Log (liveManager); //Debug.LogError("Treffer"); if (liveManager != null) { liveManager.takeDamage(damage); } Destroy(this.gameObject); }
void Start() { gameOverPanel = Instantiate(gameOverCanvas).transform.GetChild(0).gameObject; gameOverPanel.SetActive(false); gameOverText = gameOverPanel.GetComponentInChildren <Text>(); meshRenderer = GetComponentInChildren <MeshRenderer>(); if (meshRenderer != null && randomColor) { if (colorCreated) { PlayerColor = new Color(red, green, blue); } else { red = Random.Range(0F, 1F); green = Random.Range(0F, 1F); blue = Random.Range(0F, 1F); PlayerColor = new Color(red, green, blue); colorCreated = true; } meshRenderer.material.color = PlayerColor; barrel.GetComponent <MeshRenderer>().material.color = PlayerColor; particleSystemBlob.GetComponent <ParticleSystemRenderer>().material.color = PlayerColor; var col = scope.GetComponent <ParticleSystem>().colorOverLifetime; Gradient gradient = new Gradient(); gradient.SetKeys(new GradientColorKey[] { new GradientColorKey(PlayerColor, 0.0F), new GradientColorKey(Color.white, 1.0F) }, new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(0.0f, 1.0f) }); col.color = gradient; } if (isLocalPlayer) { gameOverPanel.SetActive(false); cam = Instantiate(Camera); cam.GetComponent <Follower>().target = this.transform; //Debug.LogWarning(gameObject.GetComponent<NetworkIdentity>().netId); //GameObject.FindGameObjectWithTag("StartCamera").SetActive(false); } scope.SetActive(isLocalPlayer); Cursor.visible = false; activeSpecialKeys = false; Cursor.lockState = CursorLockMode.Locked; speed = defaultSpeed; rb = GetComponent <Rigidbody> (); startPosition = transform.position; liveManager = GetComponent <NetworkLiveManager> (); liveManager.onDeath += die; }