void Awake() { _controller = GetComponent <CharacterController2D>(); _animator = GetComponent <Animator>(); _respawner = GetComponent <FallDeath>(); _flashlight = GetComponentInChildren <Flashlight>(); }
void Awake() { _controller = GetComponent<CharacterController2D>(); _animator = GetComponent<Animator>(); _respawner = GetComponent<FallDeath>(); _flashlight = GetComponentInChildren<Flashlight>(); }
void OnTriggerEnter(Collider col) { Rigidbody rig = col.transform.GetComponent <Rigidbody>(); if (rig == null) { rig = col.transform.root.GetComponent <Rigidbody>(); } ZombieMovement zmov = col.transform.root.GetComponent <ZombieMovement>(); FallDeath falldeath = col.transform.root.GetComponentInChildren <FallDeath>(); if (falldeath != null) { falldeath.FallingAnim(); } Health hcol = col.transform.root.GetComponentInChildren <Health>(); if (hcol != null) { hcol.m_killedbyPlayer = true; } if (rig != null) { GameObject tSmack = Instantiate(smackParticle, transform.position, transform.rotation); cShake.ShakeCamera(0.015f, 0.03f); PlayHitSound(col.transform.position); if (zmov != null) { zmov.DisableMovement(1); } Vector3 moveDir = (col.transform.position - transform.root.position).normalized; if (zmov != null && !zmov.unstopable) { rig.constraints = RigidbodyConstraints.None; rig.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezeRotationY; rig.useGravity = true; } rig.AddForceAtPosition(moveDir * forceMult, transform.root.position, ForceMode.Impulse); } }