User Tag List

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

Thread: Help with angle calculation!

  1. #1
    Clicker

    Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Help with angle calculation!

    Hello!

    So, I looked some smooth rotating examples and found those amazing!
    However, my game is side-scrolling and I was hoping to create a flashlight you can control with your mouse.
    And to make it work for my game I need to limit the angle. Player can only rotate it around 90 degrees. So the angle is limited, you can't look too high up or right at the floor, but around 90 degrees front of you.

    If players looks right, the light shines right and can be moved around 90 degrees.
    If player looks left, the light shines left.

    Been playing around with numbers and angles. But I can't get this to work.
    One great example suggested: (end-start+540)mod360-180
    I think that by tweaking that formula I could make it work. Any help here would be appreciated!

    Big thanks, again!

    - Jesse

  2. #2
    Clicker Fusion 2.5Android Export Module
    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)
    AftPeakTank's Avatar
    Join Date
    Apr 2013
    Location
    Greece
    Posts
    399
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    How do you move the light? I guess with the mouse...

    So what i would do is just make a fake object in the position of the center of rotation.

    Have this object to look always to an object positioned at the mouse coordinates and then,

    if the fake objects direction is greater than the upper direction you want to rich, flash-light direction = to the upper direction
    if the fake objects direction is lower than the lower direction you want to rich, flash-light direction = to the upper direction
    if it is between, flash- light direction = 1:1 with fake object direction

    Its kind of pseudo code i hope it helps... I am at the office and i don't have access to MMF2 to give you an exact example...

    Now if you want to use rotation its a different thing... More complicated... Check to see if this works for you...

  3. #3
    Clicker

    Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for reply AftPeakTank.

    Example would have been great, I can't get this to work, at least yet.
    I created an arrow as a fake object: "always look at (0,0) of my object which is paired to cordinates of my mouse"
    The arrow just sits still, it does not look at the direction of my object that's paired with mouse.

  4. #4
    Clicker Fusion 2.5Android Export Module
    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)
    AftPeakTank's Avatar
    Join Date
    Apr 2013
    Location
    Greece
    Posts
    399
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Oh i know... Go to the animation editor, scroll the direction slider to get 32 directions and right click a direction dot and rotate your object.

    Probably it does, but you dont have the animation for it. This method is not using the hardware accelerated transformation of the active. It is purely prepost graphics.

    Dont forget to position the Hot spot and Action point in the start of your arrow!

  5. #5
    Clicker

    Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ah that explains.
    I'm looking to have a very fluent rotation, so I will have to stick with HWA I guess.
    Trying to limit the angle, argh.

    Well thanks anyway! It was a good idea.

    - Jesse

  6. #6
    Clicker Fusion 2.5Android Export Module
    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)
    AftPeakTank's Avatar
    Join Date
    Apr 2013
    Location
    Greece
    Posts
    399
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    32 directions are not a few... give it a try...

  7. #7
    Clicker

    Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'm using HWA so it feels like a way to go here.
    Thou I might try that out if I can't figure this.

    Anyway, I'm getting closer:
    I created an object and I use built in mouse movement for it. My frame height is 720.
    So I use following formula: (Y( "mousepointer" )/8)-40.
    Now it goes pretty much between the angle I want it to. Thing is that if I move my mouse down, the light moves up. So I'm thinking if there is a way to reverse the math, or reverse the mouse movement?

    EDIT: I would rather create my mouse movement with Ymouse, but I don't know how to limit it so that the mouse can't leave frame. Now it goes to negative numbers and way too high.

    EDIT2: Ah I just created a box height: 720px, and use Always and overlapping to check the Y-value. And if I pull the mouse too hard so it jumps out of box, it will restore it's location depending if its too high or low. Now it seems to work quite well! Still gotta do more testing thou, and try to different way.

    - Jesse

  8. #8
    Clicker Fusion 2.5Android Export Module
    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)
    AftPeakTank's Avatar
    Join Date
    Apr 2013
    Location
    Greece
    Posts
    399
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    i think your aproach is a little strange...

    Try this...

    Active 1-> positioned always at Rotation center of flashlight
    Active 2-> X,Y of mouse

    Value Angle -> atan((A2_y - A1_y) / (A2_x - A1_x)) * 180 / PI

    Always + Check for angle < max angle or angel> min angle -> Set angle of flashlight to angle

    I don't remember exactly the events and actions available but i think you get the idea...

    You need to do some tweaking for left and right...

    This will make it totally smooth...

  9. #9
    Clicker

    Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks again mate!

    Actually my solution works very well, but your code looks much more mature so I gotta give it a try. Thanks!

    I'll report back soon enough.

    - Jesse

  10. #10
    Clicker

    Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AftPeakTank View Post
    i think your aproach is a little strange...

    Try this...

    Active 1-> positioned always at Rotation center of flashlight
    Active 2-> X,Y of mouse

    Value Angle -> atan((A2_y - A1_y) / (A2_x - A1_x)) * 180 / PI

    Always + Check for angle < max angle or angel> min angle -> Set angle of flashlight to angle

    I don't remember exactly the events and actions available but i think you get the idea...

    You need to do some tweaking for left and right...

    This will make it totally smooth...
    Sorry to bother again.
    I think I have read your post around 200 times now but can't get hang of it.
    I tried creating a value for my "Active1" called "Angle1" and type your code: atan((A2_y - A1_y) / (A2_x - A1_x)) * 180 / PI
    But it does not accept it. Syntax error. And I suck at math so finding the reason is pretty hard.

    If you have time I would appreciate few more details!

    Thank you, again!

    EDIT: For Pi I use Pi value. What confuses me most is those A2_y etc.

    - Jesse

Page 1 of 2 1 2 LastLast

Similar Threads

  1. calculation help
    By aylictal in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 21st May 2013, 02:45 PM
  2. Angle calculation bug?
    By Fanotherpg in forum SWF/Flash Export Module Version 2.0
    Replies: 2
    Last Post: 23rd April 2012, 09:38 AM
  3. Angle Calculation
    By lincore in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 17th October 2008, 12:53 PM
  4. Movement calculation
    By Chrille in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 22nd December 2007, 11:31 PM
  5. Isometric calculation
    By MechatheSlag in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 11th September 2007, 05:55 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
  •