Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Air attack

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

  1. elgatodorado

    elgatodorado

    Joined:
    Apr 7, 2019
    Posts:
    22
    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:
    1,452
    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. elgatodorado

    elgatodorado

    Joined:
    Apr 7, 2019
    Posts:
    22
    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:
    1,452
    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. elgatodorado

    elgatodorado

    Joined:
    Apr 7, 2019
    Posts:
    22
    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:
    1,452
    Good to hear!