public void Update() { if (madePlatform) { if (!whatImStuckTo.activeSelf) { whatImStuckTo = null; TurnOn(); thrown = false; } else { if (stuckToOtherPlatform) { if (!other.madePlatform) { whatImStuckTo = null; stuckToOtherPlatform = false; other = null; TurnOn(); thrown = false; } } } } }
private void OnCollisionEnter(Collision collision) { if (!madePlatform && thrown) { bool youCanStick = true; if (collision.gameObject.CompareTag("Item")) { youCanStick = false; Item item = collision.gameObject.GetComponent <Item>(); if (item.GetType() == typeof(DeployablePlatform)) { DeployablePlatform platform = (DeployablePlatform)item; if (platform.madePlatform) { youCanStick = true; stuckToOtherPlatform = true; other = platform; } else { youCanStick = false; } } } if (youCanStick) { whatImStuckTo = collision.gameObject; Debug.Log("MAKE PLATFORM"); madePlatform = true; //turn on platform platform.SetActive(true); platform.transform.eulerAngles = Vector3.zero; //turn off item rb.isKinematic = true; mr.enabled = false; collider.enabled = false; } } else { //madePlatform = true; } }