virtual protected void Awake() { _audio = GetComponent <AudioSource> (); _body = GetComponent <SMBRigidBody> (); _collider = GetComponent <SMBCollider> (); _animator = GetComponent <Animator> (); _renderer = GetComponent <SpriteRenderer> (); }
private static Vector3 DampVelocity(SMBCollider collider, float3 velocity, float3 penetrationNormal, float drag) { float3 newVelocity = math.dot(velocity, penetrationNormal) * penetrationNormal * BOUND_DAMPING + math.dot(velocity, collider.right) * collider.right * drag + math.dot(velocity, collider.up) * collider.up * drag; newVelocity = math.dot(newVelocity, new float3(0, 0, 1)) * new float3(0, 0, 1) + math.dot(newVelocity, new float3(1, 0, 0)) * new float3(1, 0, 0) + math.dot(newVelocity, new float3(0, 1, 0)) * new float3(0, 1, 0); return(newVelocity); }
private static bool Intersect(SMBCollider collider, float3 position, float radius, out float3 penetrationNormal, out float3 penetrationPosition, out float penetrationLength) { float3 colliderProjection = collider.position - position; penetrationNormal = math.cross(collider.right, collider.up); penetrationLength = math.abs(math.dot(colliderProjection, penetrationNormal)) - (radius / 2.0f); penetrationPosition = collider.position - colliderProjection; return(penetrationLength < 0.0f && math.abs(math.dot(colliderProjection, collider.right)) < collider.scale.x && math.abs(math.dot(colliderProjection, collider.up)) < collider.scale.y); }
override protected void Awake() { _collider = GetComponent <SMBCollider> (); base.Awake(); }