示例#1
0
    void CheckRiderHit(int hitPlayerIndex)
    {
        RiderStateManager otherRider = hitPlayers[hitPlayerIndex];

        // both players handle reflection
        Vector3 collisionNormal = (this.transform.position - otherRider.transform.position).normalized;

        jumpDirection = jumpDirection - 2f * (Vector3.Dot(jumpDirection, collisionNormal)) * collisionNormal;

        if (stateMachine.currentState == "JUMP" && otherRider.stateMachine.currentState == "RIDE")
        {
        }
        else if (stateMachine.currentState == "RIDE" && otherRider.stateMachine.currentState == "JUMP")
        {
            speed += (otherRider.jumpSpeed + Mathf.Abs(otherRider.speed)) * 2f * Vector3.Dot(-collisionNormal, this.tangent) * Vector3.Dot(otherRider.jumpDirection, this.tangent);
        }

        // only one player handles the speed and killing stuff
        if (Mathf.Abs(speed) > killSpeedThreshold && !OtherHasSimilarSpeed(otherRider))
        {
            Debug.Log("high speed collision, kill player " + otherRider.playerNum);
            hitPlayers[hitPlayerIndex].Kill();
        }
        else
        {
            Debug.Log("bump");
        }

        if (!otherRider.hitPlayers.Contains(this))
        {
            float tempSpeed = speed;
            speed            = otherRider.speed;
            otherRider.speed = tempSpeed;
        }
    }
示例#2
0
    bool OtherHasSimilarSpeed(RiderStateManager other)
    {
        float otherSpeed = other.speed;

        return(Mathf.Abs(speed - otherSpeed) <= killSpeedThreshold);
    }