示例#1
0
    // Used to populate the platformAdjuster delegate with the AdjustPlatform method
    // and to set the TargetPosition to be just under the ground
    public void LowerPlatform(Transform ground)
    {
        // getting the y position of the ground
        float groundPosition = ground.position.y + ground.localScale.y / 2;

        TargetPosition = new Vector3(transform.position.x, groundPosition, transform.position.z);

        platformAdjuster = AdjustPlatform;
    }
示例#2
0
    // used to adjust the position of the platform based on the targetPosition
    private void AdjustPlatform(Vector3 targetPosition)
    {
        // using smooth damp to change the position of the platform over time
        transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref currentVelocity, .05f);

        // removing the method from the platformAdjuster delegate once the platform is in its new position
        if (transform.position == targetPosition)
        {
            platformAdjuster   = null;
            transform.position = targetPosition;
        }
    }
示例#3
0
    // Used to populate the platformAdjuster delegate with the AdjustPlatform method
    // and set the TargetPosition to be the original position of the platform
    public void RaisePlatform()
    {
        TargetPosition = OriginalPosition;

        platformAdjuster = AdjustPlatform;
    }