How do I calculate vector x and vector y depending on an angle?

0 favourites
  • 7 posts
From the Asset Store
25 high-quality cars. This asset is perfect for a side scrolling game, or even a turn based RPG type game.
  • I'm trying to recreate the knockback system from the Super Smash Bros. series, but I'm a little confused as to how I might be able to input a angle that the character has been hit in and depending on knockback speed get sent in that angle with the necessary vector values. Any suggestions?

  • Do you mean opposite angle?

    ((180+angle)%360)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • That is useful for hitting a surface and getting the angle for that, but I mean like adjusting vector x and vector y to move in a certain angle.

    For an example, if a player was hit in a certain direction the velocity would be set accordingly. This is fairly straight forward for 8 basic directions, but I was wondering how I could do the angles inbetween.

    Knockback (K) = 100

    Left - Vector X: K*-1, Vector Y: K*0

    Left Up - Vector X: K*-0.5, Vector Y: K*-0.5

    Up - Vector X: K*0, Vector Y: K*-1

    Up Right - Vector X: K*0.5, Vector Y: K*-0.5

    Right - Vector X: K*1, Vector Y: K*0

    Down Right - Vector X: K*0.5, Vector Y: K*0.5

    Down - Vector X: K*0, Vector Y: K*1

    Down Left - Vector X: K*-0.5, Vector Y: K*0.5

  • X=100*cos(ang)

    Y=100*sin(ang)

    For any angle.

  • X=100*cos(ang)

    Y=100*sin(ang)

    For any angle.

    R0J0hound, I need your help. I need your help. Can you give me your e-mail, I'll ask there. I have a pot and a net. When the basket moves, the net moves very badly. I need to solve this. Can you give your e-mail? My email: sarierdncnvz@gmail.com

  • X=100*cos(ang)

    Y=100*sin(ang)

    For any angle.

    Seems like this is what I was looking for, much appreciated.

  • oraflame

    Glad it helped.

    sarierdnc

    Best to create a new topic. Generally I’m unavailable but when I am I’d just skim all the posts and reply to those that interest me, I have time for and I actually can solve. That said there are many other talented people on here that like to help out too. So a new topic is your best bet.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)