User Tag List

Results 1 to 4 of 4

Thread: Knockback based on attack direction

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export ModuleInstall Creator Pro
    Shadeve's Avatar
    Join Date
    Aug 2011
    Location
    GA USA
    Posts
    216
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Knockback based on attack direction

    Hi, I need help with some complex formulas. My game is an 8 direction topdown RPG. When my players sword collides with an enemy, I just want one event to determine sword direction and knockback the enemy the correct direction.

    Right now, I have to use conditions like:

    If sword is facing direction right, then position enemy x+10

    and do that for all directions. Anyone know the formula I can use to do it in just one event?

  2. #2
    Clicker Fusion 2.5
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    570
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You can use the angle from the player to the enemy, and apply knockback that way with sin/cos functions: angle knockback.mfa (arrow keys move enemy, spacebar pushes back)

    Now it will get knocked back perfectly no matter what angle it's at with one event (you can set the angle in the knockback event itself if you want). Make sure to use the angle from player to enemy instead of sword to enemy, unless you specifically need the sword to control the angle. It might make your enemy shoot towards the player depending on where your sword's hotspot is.

  3. #3
    Clicker Android Export Module

    Join Date
    Feb 2010
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like you need cos and sin

    Set X = currentX + cos(direction / 11.25) * 10
    Set Y = currentY - sin(direction / 11.25) * 10

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export ModuleInstall Creator Pro
    Shadeve's Avatar
    Join Date
    Aug 2011
    Location
    GA USA
    Posts
    216
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help!

Similar Threads

  1. Calculating a direction based on player object
    By VinnieG in forum Fusion 2.5
    Replies: 4
    Last Post: 7th May 2018, 02:48 PM
  2. Direction of Based Death Animation
    By jackisawesome3 in forum Fusion 2.5
    Replies: 1
    Last Post: 25th April 2016, 10:06 PM
  3. Set Initial Direction based on conditions
    By wiggy in forum Fusion 2.5
    Replies: 14
    Last Post: 1st August 2015, 10:31 PM
  4. Detecting the direction of an attack
    By Atherton in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 19th October 2009, 02:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •