User Tag List

Results 1 to 9 of 9

Thread: Closest instance for radial volume

  1. #1
    Clicker Multimedia Fusion 2
    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)
    FlipSwitchX's Avatar
    Join Date
    Feb 2012
    Location
    California
    Posts
    206
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Closest instance for radial volume

    So I've read all the threads I could find about this and downloaded many examples but I still couldn't manage to find what I needed.

    I have the volume increasing and decreasing according to distance, only there are several instances of the object that is "making" the sound.
    I want to make the radius of sound work for the object of which I am currently closest.

    I tried something like this which probably looks ridiculous:

    If, Sqr((Xobject-Xplayer)pow2 + (Yobject-Yplayer)pow2) = Floor(Sqr((Xobject-Xplayer)pow2 + (Yobject-Yplayer)pow2))
    then, Set volume to 100-Sqr((Xobject-Xplayer)pow2 + (Yobject-Yplayer)pow2)/3.5

    My logic was that it would compare the distance between object and player and compare it to the lowest instance and if it was indeed the lowest instance then it would use that instances distance to calculate the volume, myes.

    Unfortunately no, that doesn't work. (also I used Abs(), I just left it out there for simplicity.)

    So then I said forget the hypotenuse method for determining which instance was closest I will just use X positions to make a detection "column" for when I'm near (sort of defeating the purpose of the volume radius I know).

    I tried If, Xobject <= Xplayer + 150
    and, Xobject >= Xplayer - 150, then, set flag 0 on. If flag is on set volume to etc.

    If Xobject >= Xplayer + 150 set flag off.
    If Xobject >= Xplayer - 150 set flag off.

    Now I'm thinking I probably need to spread a value of the object and run a fastloop that compares the distance to the player for each object and.... flags the lowest one... somehow...
    I'm not so great with fastloops and going through lists of instances...

    Right now It is sort of working It just favors one object over another so I have to get out of one objects radius before the other one kicks in but i want it to be more like in the example doodle i attached.
    Images attachées Images attachées

  2. #2
    Clicker Multimedia Fusion 2
    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)
    FlipSwitchX's Avatar
    Join Date
    Feb 2012
    Location
    California
    Posts
    206
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    or I mean I have to get out of the dominant objects "x zone" before the radius of the other object kicks in.
    also there will be more than 2 objects so I can't just use the average to determine which one I'm closest to.

  3. #3
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    This question gets asked over and over - searching for "Tower Defense" would be a good start...

  4. #4
    Clicker Multimedia Fusion 2
    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)
    FlipSwitchX's Avatar
    Join Date
    Feb 2012
    Location
    California
    Posts
    206
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I keep looking at examples. I'm trying really hard to understand what I have to do with the ForEach object but I just don't know what I'm doing =\ exam.jpg In the objects behavior code I have always set Alt val B to the distance between it and the player. I just don't know what to do with Alt Val B at this point

  5. #5
    Clicker Multimedia Fusion 2
    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)
    FlipSwitchX's Avatar
    Join Date
    Feb 2012
    Location
    California
    Posts
    206
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    i changed the animation sequence to bouncing there just to try to get a visual representation of whats going on and it seems they flash that animation indiscriminately. oi what is floor() for anyway if you cant say if one thing equals the lowest of the bunch @____@

  6. #6
    Clicker Multimedia Fusion 2
    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)
    FlipSwitchX's Avatar
    Join Date
    Feb 2012
    Location
    California
    Posts
    206
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I went over that tower defense example and i couldn't see how it was picking the closest object it had something to do with groups and at this point my game has many frames and that would be, really, tedious. Also it was picking the closest thing to shoot at, A bit different from picking the closest thing and then setting the volume based on that things ... distance..

    please, could someone explain or point me to a foreach loops example ?

  7. #7
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Alright, here's a very simple solution, using the "Select Object" extension...
    Give each object an alterable value called "Distance".

    + Always
    -> Object: Set Distance to Sqr(((X("Object")-X("Player")) pow 2)+((Y("Object")-Y("Player")) pow 2))

    + Select Object: Select single "Object" with lowest "Distance"
    + Set volume to 100 - (Distance("Object") / 3.5)

  8. #8
    Clicker Multimedia Fusion 2
    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)
    FlipSwitchX's Avatar
    Join Date
    Feb 2012
    Location
    California
    Posts
    206
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Thanks I got a Select Object example file and tried it out in there and it worked but I copied the exact same thing over to the .mfa I've been working on for a while and it wouldn't work. Go figure I'll chalk it up to bad luck this time. It's not a feature I desperately need after all, and next time If I start from a fresh file I'm sure it would work. Something musta been tweaked or incompatible. I've saved this .mfa over multiple versions of mmf so, oh well. Thanks !

  9. #9
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Before you scrap it, take a minute to check and make sure you're not using that variable already somewhere. If you made it in a new project, you're probably using Alterable Value A for Distance, but you've probably already used that in your main project, so when you copy it over you'll have conflicting events setting and accessing the Distance value. If this is the case, just replace it with a value you haven't used.

Similar Threads

  1. Distance Code Reliability vs. Radial Detector Object
    By Kid_Roleplay in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 26th December 2012, 07:02 PM
  2. Volume keys should change multimedia volume
    By qenio in forum Android Export Module Version 2.0
    Replies: 2
    Last Post: 14th October 2012, 09:56 AM
  3. Master Volume, Channel Volume, Sound Volume
    By BHGames in forum iOS Export Module Version 2.0
    Replies: 14
    Last Post: 18th December 2010, 12:11 PM
  4. Radial gradient transparency mask
    By vertigoelectric in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 3rd February 2009, 10:13 PM
  5. Volume of a specific instance of a sample
    By Dines in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 19th June 2008, 09:02 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
  •