void SetAnimatorSpeeds() { //Only care about absolute speed for distinguishing between idle and running animator.SetFloat("AbsoluteHorizontalSpeed", Mathf.Abs(characterMovement.GetHorizontalSpeed())); //Care about sign for vertical speed to distinguish rising and falling. animator.SetFloat("VerticalSpeed", characterMovement.GetVerticalSpeed()); }
protected void ResolveCollision(GameObject other) { CharacterCorpus corpus = other.GetComponent <CharacterCorpus> () as CharacterCorpus; Character character = other.GetComponent <Character> () as Character; if (corpus != null) { if (character != null) { if (character != this.componentData.GetCharacter()) { if (bounceCasterOnHit) { CharacterMovementActuator castingAcuator = componentData.GetMovementActuator(); if (castingAcuator != null) { if (castingAcuator.GetVerticalSpeed() < -1f) { if (castingAcuator.transform.position.y > corpus.transform.position.y) { castingAcuator.BounceCommand(16f); corpus.TakeDamage(damage, firingTeam); corpus.TakeKnockback(worldLaunchVector, knockbackSpeed); } } } } else { corpus.TakeDamage(damage, firingTeam); corpus.TakeKnockback(worldLaunchVector, knockbackSpeed); } if (destroyOnCharacterContact) { DestroyProjectile(); } } } } if (other.gameObject.layer == 8) //If other is terrain { if (destroyOnTerrainContact) { DestroyProjectile(); } } if (deflectsProjectiles) { if (other.gameObject.layer == 13) //If other is a projectile(ranged) { Rigidbody body = other.GetComponent <Rigidbody>() as Rigidbody; if (body != null) { Transform castingTransform = componentData.GetCharacterTransform(); if (castingTransform != null) { Vector3 toOtherProj = other.transform.position - castingTransform.position; toOtherProj.Normalize(); float otherProjSpeed = body.velocity.magnitude; body.velocity = otherProjSpeed * toOtherProj; } } } } }