using System.Collections; using System.Collections.Generic; using UnityEngine; public class SpikesController : MonoBehaviour { public GameObject player; public int damage; public CameraController cc; // Use this for initialization void Start() { cc = GameObject.FindGameObjectWithTag("MainCamera").GetComponent(); } // Update is called once per frame void Update() { player = GameObject.FindGameObjectWithTag("Player"); } private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Player") { player.GetComponent().health -= damage; cc.isShakcing = true; } } }