How to make an attack that moves the players position relative the target.

Hi, I’m trying to make an attack that… well, it does a few things.

When the attack key is pressed, the player character dashes forward a bit, and if any enemy is hit during this period, the attack commences (I have this).

When the attack commences, the player character leaps up to the enemies face and kicks them a bunch
of times (in a short channel).(I’m stumped here. This is my question^)

-Then the player leaps off them (I think I can get this pretty easily).
_
Currently I have it so every enemy has a child object with a Transform, which is passed to the player character upon collision. I also have it so the player character has a child object at her feet (at the position I want the “kicks” to happen). I am using only static and kinematic ridgibodies. I am quite stumped on how to make the logic to move the player character’s “kick point” in an arc up to their “face point”. It should be noted this attack can only happen while grounded. Any help would be appreciated! Thanks in advance!

Actually I figured out a solution. I’ll post my solution here in a bit.

EDIT: So this is the code that executes when the player presses the attack key:

 public void ComboAttackTry()
    {
        animStuff.SetLayerWeight(1, .9f);
        if (currentState != AttackState.ComboHit|| currentState != AttackState.ComboLaunch)
            currentState = AttackState.ComboTry;

        foxMoveStuff.GetCurrentDirection(lastKey);

        foxMoveStuff.canMoveNormal = false;
        comboBox.SetActive(true);
        isDoingAttack = true;



        if (Mathf.Abs(foxMoveStuff.realSpeed) > foxMoveStuff.maxSpeed && !comboBool)
        {

            foxMoveStuff.realSpeed = Mathf.MoveTowards(foxMoveStuff.realSpeed, 0, (foxMoveStuff.realSpeed * speedMultDelta) * Time.deltaTime);
            speedMultDelta = Mathf.Lerp(0, 2, Mathf.MoveTowards(speedMultDelta / 2, 1, foxMoveStuff.realSpeed * Time.deltaTime));
        }
        else
        {
            if (!comboBool)
            {
                foxMoveStuff.realSpeed = 15;
                comboBool = true;
                stunEnemey = true;
                tempLastKey = lastKey;
            }
            else
            {
                foxMoveStuff.realSpeed = Mathf.MoveTowards(foxMoveStuff.realSpeed, 0, 30 * Time.deltaTime);
                playerStuff.directionalInput.x = tempLastKey;
                stunEnemey = true;

            }
        }

        if (foxMoveStuff.realSpeed == 0 && !wasHit)
        {
            currentState = AttackState.NotAttacking;
            animStuff.SetLayerWeight(1, 0);
            attackLengthCount = 0;
            comboBox.SetActive(false);
            foxMoveStuff.canMoveNormal = true;
            isDoingAttack = false;
            comboBool = false;
            stunEnemey = false;
            ResetVars();
            foxMoveStuff.ResetVars();

        }

        if (wasHit)
        {
            
            if (attackLengthCount < comboAttackFrameDuration)
            {
                attackLengthCount += 1;
                ComboAttackHit();
                
            }
            else if(attackLengthCount>=comboAttackFrameDuration)
            {
                if (attackLengthCount == comboAttackFrameDuration)
                    comboDealDam = true;

                currentState = AttackState.ComboLaunch;
                animFlpStuff.enabled=false;
                if (attackLengthCount <= comboAttackFrameDuration + 15)
                {
                    attackLengthCount += 1;

                    if (attackLengthCount <= comboAttackFrameDuration + 5)
                        playerStuff.velocity.y = playerStuff.velocity.y == 0 ? 7 : Mathf.MoveTowards(playerStuff.velocity.y, .1f, 40 * Time.deltaTime);
                    else
                        playerStuff.velocity.y = Mathf.MoveTowards(playerStuff.velocity.y, -10, 200 * Time.deltaTime);

                    playerStuff.velocity.x = attackLengthCount <= comboAttackFrameDuration + 2 ? -35 * tempLastKey : Mathf.MoveTowards(playerStuff.velocity.x, .1f, 2 * Time.deltaTime);



                }
                else
                {
                    comboDealDam = false;
                    animFlpStuff.enabled = true;
                    currentState = AttackState.NotAttacking;
                    animStuff.SetLayerWeight(1, 0);
                    playerStuff.gravity = -48;
                    attackLengthCount = 0;
                    comboBox.SetActive(false);
                    foxMoveStuff.canMoveNormal = true;
                    isDoingAttack = false;
                    comboBool = false;
                    stunEnemey = false;
                    wasHit = false;
                    playerStuff.velocity.x = .1f * tempLastKey;
                    ResetVars();
                    foxMoveStuff.ResetVars();
                }
            }
        }
    }

    public void ComboAttackHit()
    {
        currentState = AttackState.ComboHit;

        foxMoveStuff.canMoveNormal = false;
        playerStuff.gravity = 0;

        if ((tempLastKey==1&&comboKickFaceBox.position.x>enemeyFaceLocation.x)||(tempLastKey==-1&&comboKickFaceBox.position.x<enemeyFaceLocation.x))
        {
            playerStuff.velocity.x = 0;   
        }
        else if (comboKickFaceBox.position.x != enemeyFaceLocation.x )
        {
            playerStuff.velocity.x = 4* tempLastKey;
        }

        if (comboKickFaceBox.position.y>enemeyFaceLocation.y)
        {
            playerStuff.velocity.y = 0;
        }
        else if (comboKickFaceBox.position.y != enemeyFaceLocation.y && comboKickFaceBox.position.y < enemeyFaceLocation.y)
        {    
            playerStuff.velocity.y = playerStuff.velocity.y==0?10: Mathf.MoveTowards(playerStuff.velocity.y,1,Time.deltaTime);
        }
    }

Hopefully a person of the future will find it useful. :slight_smile: