User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Creating object and placing it depending on direction?

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Unknowner's Avatar
    Join Date
    Oct 2011
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Creating object and placing it depending on direction?

    Hi, I have a player who looks in direction of mouse always, when I click left button I want to create and position the object in front of player direction, how can I achieve this?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,157
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    You can try this:

    on left button click
    >>> set (a temporary value) to ATan2(Y("player") - ymouse, xmouse - X("player"))
    >>> create object wherever
    >>> set object X position to X player + cos(that temporary value) * (distance you want to place the object)
    >>> set object Y position to Y player - sin(that temporary value) * (distance you want to place the object)

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Unknowner's Avatar
    Join Date
    Oct 2011
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by schrodinger View Post
    You can try this:

    on left button click
    >>> set (a temporary value) to ATan2(Y("player") - ymouse, xmouse - X("player"))
    >>> create object wherever
    >>> set object X position to X player + cos(that temporary value) * (distance you want to place the object)
    >>> set object Y position to Y player - sin(that temporary value) * (distance you want to place the object)
    thanks, works like I charm, don't think I could do that alone by my self!

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,157
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Glad to help
    btw, if you aren't already using "angles" for your player,
    you could also "always" set the "angle" of player to that ATan2 formula,
    "look at mouse" with object direction has only (max) 32 steps while angle has 360.00 so it's much smoother
    but depends on case-use (if you have custom animations for each direction this won't work good of course )

  5. #5
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Unknowner's Avatar
    Join Date
    Oct 2011
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by schrodinger View Post
    Glad to help
    btw, if you aren't already using "angles" for your player,
    you could also "always" set the "angle" of player to that ATan2 formula,
    "look at mouse" with object direction has only (max) 32 steps while angle has 360.00 so it's much smoother
    but depends on case-use (if you have custom animations for each direction this won't work good of course )
    I'm alredy doing that but I was thinking about something, imagine I have an enemy that his movement is a bouncing ball, how can I set his angle to his direction? since my player is ATan2(Y( "torso" ) - YMouse, XMouse - X( "torso" )), for what I'm supposed to change ymouse, xmouse? something like actual direction of enemy?

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,157
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Sorry not sure I understood,
    you can convert between angle and "Fusion" direction by dividing angle/11.25

    So if you want a bouncing ball enemy to have angle based on his direction, set angle do dir*11.25

    But if you want full 360 degrees you can't use bouncing ball,
    you'd have to change to "Physics" bouncing ball,
    or code your own custom movement

  7. #7
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Unknowner's Avatar
    Join Date
    Oct 2011
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by schrodinger View Post
    Sorry not sure I understood,
    you can convert between angle and "Fusion" direction by dividing angle/11.25

    So if you want a bouncing ball enemy to have angle based on his direction, set angle do dir*11.25

    But if you want full 360 degrees you can't use bouncing ball,
    you'd have to change to "Physics" bouncing ball,
    or code your own custom movement
    Not sure if is that, ill try to explain better. I have a enemy that is a bouncing ball, I want the animation turn around to the direction he is moving, but I don't want to use a rotated animation it looks ugly, I want the animation turn around like player can do when he has that formula "ATan2(Y( "Player" ) - YMouse, XMouse - X( "Player" ))" turning around to mouse direction, but instead of mouse, using his own movement direction

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,157
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Mmm like smoothly turning towards the new direction?
    Something like this perhaps?

    look_to_dir.mfa

    (always-foreach might not be strictly required, could be optimized a bit if necessary, depending on real-use)

  9. #9
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Unknowner's Avatar
    Join Date
    Oct 2011
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by schrodinger View Post
    Mmm like smoothly turning towards the new direction?
    Something like this perhaps?

    look_to_dir.mfa

    (always-foreach might not be strictly required, could be optimized a bit if necessary, depending on real-use)
    The use is having a single image (top down character) and while the enemy is walking around to random directions image needs to follow properly, just that, but seems kinda to much a for each for that no?

    Edit: Instead of open a new thread ill ask u here, i'm trying to do the same as I did with player about player angle follow my mouse but now I want to achieve this:

    I have a turret with a vision radius, when enemy enter on radius turret must look in direction of enemy, is there a way to do it with angles instead of 36 images of turret rotation and look in direction?

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,157
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    The use is having a single image (top down character) and while the enemy is walking around to random directions image needs to follow properly, just that, but seems kinda to much a for each for that no?
    well, depends, might be totally feasible if you have not too many enemies and not too much intensive stuff going on,
    you could trigger a "scoped" foreach to address only those enemies changing direction
    but depends pretty much on your game

    actually, you can remove always event and "foreach" statements from the example above,
    it should work anyway, but there is no significant speed improvement, and I find myself safer with foreachs

    I have a turret with a vision radius, when enemy enter on radius turret must look in direction of enemy, is there a way to do it with angles instead of 36 images of turret rotation and look in direction?
    Yes, if you don't want to use ATan2, you can simply do:

    enemy overlaps vision radius
    >>> start loop foreach vision radius

    on each vision radius
    +enemy overlaps vision radius
    +turret id=visionradius id
    >>> turret set angle to Atan2(Yturret-Yenemy,Xenemy-Yturret)

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Placing light around a projectile object
    By Hidronax in forum Fusion 2.5
    Replies: 5
    Last Post: 16th August 2016, 07:05 PM
  2. Placing object by mouse
    By Outcast in forum Fusion 2.5
    Replies: 12
    Last Post: 27th August 2015, 10:49 AM
  3. Replies: 2
    Last Post: 12th January 2015, 11:31 PM
  4. Creating and Placing Objects
    By Tobias2189 in forum Fusion 2.5
    Replies: 1
    Last Post: 17th July 2014, 10:51 AM
  5. Changing volume depending on distance to object?
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 3rd February 2012, 01:04 PM

Posting Permissions

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