User Tag List

Results 1 to 4 of 4

Thread: Midpoint Camera Distance Restriction

  1. #1
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    642
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Midpoint Camera Distance Restriction

    Hi everyone!

    So I'm trying to make a special camera that positions itself at the midpoint between two points (the player and the mouse cursor). I used the midpoint formula to position the camera in the frame;

    midpt07.gif

    Then I tested the frame and it works well, but the user can move his mouse super far away and see things way off the screen. I decided to add the distance formula to restrict how far away the camera can be from the player;

    dist07b.gif

    However once the player reaches past the specified distance, the code stops working and the camera isn't positioned (as I expected). The question is, how can I keep the camera from moving past the set distance while still following the mouse and rotating around the player. Imagine a bubble around the player and the max distance would be the edges of the bubble. the mouse should still be able to move and rotate around the player at the fixed max distance. Here's the short few lines of code that I have so far. I assume I'll have to test if the distance is greater than 750 pixels, then add some code...

    Screen Shot 2015-08-07 at 10.44.20 AM.jpg

  2. #2
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    642
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I found this information online:

    In general, suppose that you are rotating about the origin clockwise through an angle θ. Then the point (s,t) ends up at (u,v) where
    u=scosθ+tsinθ and v=−ssinθ+tcosθ.

    I'm going to figure out the angle between using ATan2 and hopefully this should work.

  3. #3
    Clickteam Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleInstall Creator Pro
    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)
    BartekB's Avatar
    Join Date
    Aug 2013
    Posts
    667
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    +Always
    ----Set Distance_Value to ( ODistance( "Player", xmouse, ymouse ) )
    ----Set Angle_Value to ( AdvDirection( "Advanced Direction Object", plr_x, plr_y, xmouse, ymouse ) )
    ----Set Camera_X_Value to ( Sin( Angle_Value )*Range(Distance_Value * 0.5, 0, 200 ) )
    ----Set Camera_Y_Value to ( Cos( Angle_Value )*Range(Distance_Value * 0.5, 0, 200 ) )
    ----Set Camera Position X to ( plr_x + Camera_X_Value )
    ----Set Camera Position Y to ( plr_y + Camera_Y_Value )

    I used the Advanced Direction Object for this.

    EDIT: For MMF2, use the Advanced Direction Object for getting the distance as well. I'm also not sure if there is a "range" expression in the special conditions object

    EDIT2: Yeah there is no range expression. you can either way check the distance, then check if it is above #, then set the distance to #
    EDIT3: MMF2 Version:

    +Always
    ----Set Distance_Value to ( Distance("Advanced Direction Object", plr_x, plr_y , xmouse, ymouse ) )
    ----Set Angle_Value to ( AdvDirection( "Advanced Direction Object", plr_x, plr_y, xmouse, ymouse ) )

    +IF Distance_Value > 120
    ----Set Distance_Value to ( 120 )

    +Always
    ----Set Camera_X_Value to ( Sin( Angle_Value )*(Distance_Value * 0.5) )
    ----Set Camera_Y_Value to ( Cos( Angle_Value )*(Distance_Value * 0.5) )
    ----Set Camera Position X to ( plr_x + Camera_X_Value )
    ----Set Camera Position Y to ( plr_y + Camera_Y_Value )
    - BartekB, a.k.a Uppernate
    Join the Click Converse Discord! - https://discord.gg/R3WuvF3mHr

  4. #4
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    642
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks BartekB, it works now I've added my .mfa file in case anyone else would like to use it. I decided to use the traditional mathematical formulas for distance and angle calculations so I didn't have to include the Advanced Direction Object.
    Attached files Attached files

Similar Threads

  1. IP Camera and Web Camera Extension for MMF2
    By droberson in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 2nd June 2010, 05:37 PM
  2. Condition ID restriction
    By James in forum Released Extensions
    Replies: 1
    Last Post: 4th December 2007, 05:28 PM
  3. movement restriction
    By splokk in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 6th September 2007, 05:01 PM
  4. Midpoint Scrolling
    By Mr_Monkey in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 8th January 2007, 05:45 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
  •