示例#1
0
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//////These are functions we will use in the script
//////
//////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////



    float GetXVelocityJenny()
    {
        float Vx = platformerController.GetSpeed();

        //float Vx = rigidbody.velocity.x;
        return(Vx);       // Vx is the float returned by GetXVelocity
    }
示例#2
0
    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (hit.gameObject.name == "Spaceship")
        {
            hit.gameObject.SendMessage("EnterSpaceship", SendMessageOptions.DontRequireReceiver);
            return;
        }

        Rigidbody body = hit.collider.attachedRigidbody;

        // no rigidbody
        if (body == null || body.isKinematic)
        {
            return;
        }

        // Only push rigidbodies in the right layers
        int bodyLayerMask = 1 << body.gameObject.layer;

        if ((bodyLayerMask & pushLayers.value) == 0)
        {
            return;
        }

        // We dont want to push objects below us
        if (hit.moveDirection.y < -0.3)
        {
            return;
        }

        // Calculate push direction from move direction, we only push objects to the sides
        // never up and down
        Vector3 pushDir = new Vector3(hit.moveDirection.x, 0, hit.moveDirection.z);

        // push with move speed but never more than walkspeed
        body.velocity = pushDir * pushPower * Mathf.Min(controller.GetSpeed(), controller.movement.walkSpeed);
    }