Ejemplo n.º 1
0
    private void FixedUpdate()
    {
        Vector3 newPosition = transform.position;
        Vector3 oldPos      = transform.position;
        Vector3 oldLocalPos = transform.localPosition;

        switch (CurrentAction)
        {
        case (LincolnAction.Rising):
            //float curY = newPosition.y;
            if (oldLocalPos.y < riseHeight)
            {
                newPosition.y += riseSpeed;
            }
            else
            {
                CurrentAction = LincolnAction.StompPositioning;
            }
            break;

        case (LincolnAction.StompPositioning):
            int   dir             = 1;
            float distanceToStomp = 0.5f;
            if (Mathf.Abs(oldPos.x - targetPos.Value.x) < distanceToStomp)
            {
                CurrentAction = LincolnAction.Stomping;
                break;
            }

            if (targetPos.Value.x < oldPos.x)
            {
                dir = -1;
            }
            newPosition.x += stompPositioningSpeed * dir;
            break;

        case (LincolnAction.Stomping):
            if (oldLocalPos.y > -0.2f)
            {
                newPosition.y -= stompSpeed;
            }
            else
            {
                CurrentAction = LincolnAction.Rising;
            }
            break;

        default:
            break;
        }

        transform.position = newPosition;
    }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 protected override void Start()
 {
     base.Start();
     CurrentAction = LincolnAction.Rising;
 }