Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Air attack

Discussion in '2D' started by migbernabeumor, Aug 10, 2019.

  1. migbernabeumor

    migbernabeumor

    Joined:
    Apr 7, 2019
    Posts:
    16
    Hello im making my first game and i didnt find information about air attacks in a platformer 2d.

    Im trying to do an air attack but gravity(I have -34 as gravity acceleration) is making my attack to feel heavy and create a curve.

    My attack goes in the direction of the mouse when the player clicks.

    My question is, how can i compensate gravity to make my attack feels great?

    This is the way i do my movement with the attack:

    -attackVector is my normalized vector that goes in the direction of the mouse.

    Code (CSharp):
    1. myBody.AddForce(attackVector* 11, ForceMode2D.Impulse);
    Thank you for read this and your time.
     
  2. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    102
    You could mess with the mass of the projectile or change the gravity force of the object to mess with some interesting shots. Or do you not want it to curve at all?
     
  3. migbernabeumor

    migbernabeumor

    Joined:
    Apr 7, 2019
    Posts:
    16
    Im very clueless and i forgot to say that my attack is melee.

    When the character attacks does a curve because the gravity.

    Moreover i tried to touch the gravity of my character but doing this looks like my character is in the space and looks more weird.

    I think now you see why i dont want my character to do that curve.

    Thank you for your time.
     
  4. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    102
    Good to know it is melee, but i am still having a hard time figuring out why it would curve at all since its melee. Can you post a screen shot of the attack? Is it a sword swing, punch, etc.? I cant imagine a melee attack curving since normally it is an animation of some sort.
     
  5. migbernabeumor

    migbernabeumor

    Joined:
    Apr 7, 2019
    Posts:
    16
    I fixed this problem, well my attack curved in the air because the gravity force (-34) was too intense I "fixed" this adding a Vector2.up now looks great. Thank you for your time.
     
  6. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    102
    Good to hear!