User Tag List

Results 1 to 9 of 9

Thread: Math question

  1. #1
    No Products Registered

    Join Date
    Mar 2009
    Posts
    412
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Math question

    I have a waterfall in my game, and I want the waterfall to have the sound higher when you are closer and lower when you go away. Heres the thing.

    The main object that controls the waterfall sound is a small active object that is placed in the middle of the waterfall, with 200 pixels of waterfall to each side. It has only one action so far:

    Always: Set Alterable Value A to ABS(X("Player")-X("WFsound")

    So Im basing the sound on this. I know that the sound volume can only go from 0-100, so I have the idea of making this all in percent. The max length of the player to hear the sound will start at 650 pixels away, and the max length will start when he is at the edge of the waterfall, which basically is 200 pixels away. Does anyone have any suggestion on how to set this as an event in the Always: Set sample volume... ?

    Lowest volume at 0 when Alterable Value A is 650.
    Highest volume at 100 when Alterable Value A is 200 or lower.

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Math question

    You should use the distance formula instead.
    As for the formula, think of it as a proportion that you need to solve for x: (along with a few min() and max() operations)
    200*******x
    ----**=**----
    650*****100
    (hopefully I got this math right, it's really early in the morning for me)

    The min() and max() would be for not allowing overflow in the calculations of the volume.
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Math question

    Volume = Max( 0 , Min( 100 , -( Distance -650)/4.5 ) )

  4. #4
    No Products Registered

    Join Date
    Mar 2009
    Posts
    412
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Math question

    Its probably obvious for you guys how to do this, but I have never used Max, Min or Distance in my projects.

    Volume = Max( 0 , Min( 100 , -( Distance -650)/4.5 ) )
    Should this go as an Always event? Or are we still talking about Alterable Value A? Anyhow, I cant see any relations to the active WFSound object, which kinda is the base for the distance.. :S

  5. #5
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Math question

    Yeah, 'always' event where you are setting the volume to

    Max( 0 , Min( 100 , -( Alterable Value A -650)/4.5 ) )

  6. #6
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Math question

    "Distance" is what jax intended you to replace by your distance formula. Min() returns the lowest of two numbers, and Max() returns the highest of two numbers.

    Min(1, 3) = 1
    Max(1, 3) = 3

    Min(5, -6) = -6
    Max(5, -6) = 5

    Working as fast as I can on Fusion 3

  7. #7
    No Products Registered

    Join Date
    Mar 2009
    Posts
    412
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Math question

    Ah yea Im getting the picture

    But it appears to be a problem when I try to enter the minus before (Alterable Value A).. It then makes a syntax error. Its valid if I remove it. Do I do something wrong?

  8. #8
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    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)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    Phi's Avatar
    Join Date
    Jan 2010
    Location
    England
    Posts
    1,964
    Mentioned
    25 Post(s)
    Tagged
    0 Thread(s)

    Re: Math question

    try using *-1... or change the signs of the bracket's contents.

  9. #9
    No Products Registered

    Join Date
    Mar 2009
    Posts
    412
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Math question

    I think Ill just remove this whole thing. Turns out the "fancy" watersplash I made probably decreased the framerate a bit.

    Changing the signs would probably work.. I should have though of that by myself actually :P

    Thanks a lot to all :]

Similar Threads

  1. Math Logic Question
    By JimmyTHicks in forum The Games Factory 2 - Technical Support
    Replies: 2
    Last Post: 31st August 2012, 01:30 AM
  2. Math formula question
    By FlinkGigitty in forum Multimedia Fusion 2 - Technical Support
    Replies: 43
    Last Post: 6th October 2010, 06:08 PM
  3. Quick math question
    By LaraSoft in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 26th December 2007, 10:16 AM
  4. [Question about speed] Animation or Math?
    By Durnus in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 28th January 2007, 03:23 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
  •