Ejemplo n.º 1
0
    /// <summary>
    /// The target object is held in hand.
    /// </summary>
    /// <param name="ac">The player's action controller</param>
    void HoldInHand(PlayerActionController ac)
    {
        ac.SetHeldObject(this, this.heldHandType, inHand:true);

        // This object disappears, as it will appear in hand
        this.gameObject.SetActive(false);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// The target object is picked up.
    /// </summary>
    /// <param name="ac">The player's action controller</param>
    void PickUp(PlayerActionController ac)
    {
        ac.SetHeldObject(this, this.heldHandType);

        // Parenting: uncomment this to achieve non-physical motion
        //this.transform.parent = ac.pickingUpPivotTr;

        this.physicsCollider.gameObject.layer = LayerMask.NameToLayer("PickedupObject");

        // Follow the position
        var posAttractor = GetComponent<PositionAttractor>();
        posAttractor.heightIsNotAffected = false;
        posAttractor.targetTr = ac.pickingUpPivotTr;
        posAttractor.enabled = true;

        // Follow the rotation
        var rotAttractor = GetComponent<OrientationAttractor>();
        rotAttractor.targetTr = ac.pickingUpPivotTr;
        rotAttractor.enabled = true;

        // No gravity
        this.rigidbody.useGravity = false;
    }
Ejemplo n.º 3
0
    /// <summary>
    /// The target object is dragged around.
    /// </summary>
    /// <param name="ac">The player's action controller</param>
    void Drag(PlayerActionController ac)
    {
        ac.SetHeldObject(this, this.heldHandType);

        this.physicsCollider.gameObject.layer = LayerMask.NameToLayer("PickedupObject");

        // Follow the position
        var posAttractor = GetComponent<PositionAttractor>();
        posAttractor.heightIsNotAffected = true;
        posAttractor.targetTr = ac.pickingUpPivotTr;
        posAttractor.enabled = true;

        // Follow the rotation
        var rotAttractor = GetComponent<OrientationAttractor>();
        rotAttractor.targetTr = ac.pickingUpPivotTr;
        rotAttractor.enabled = true;

        // Slow down player
        Statics.instance.playerMovementController.SetSpeedModifier(0.5f);
        Statics.instance.playerMovementController.DisableJump();

        // No gravity
        this.rigidbody.useGravity = true;
    }