User Tag List

Results 1 to 3 of 3

Thread: Fish Movement Bug?

  1. #1
    Clicker Multimedia Fusion 2
    Wolfking_Warrior's Avatar
    Join Date
    Aug 2012
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Fish Movement Bug?

    Hello again!

    I have an issue with a piece of code.

    In it, fish are set to move towards a guide with a random speed, and with a random Y above the guide.
    For some reason, the fish won't move, and if I set the speed higher, they move too fast.

    Can someone take a look and tell me what I'm doing wrong?

    MFA: Fish Movement.mfa

    -Wolfking_Warrior

  2. #2
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleXNA 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)
    gkinfinity's Avatar
    Join Date
    May 2011
    Location
    USA
    Posts
    284
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    There are a couple of things I'd like to point out for you.

    Random(x) generates a number between 0 and x-1. This means that Random(11) will generate a number between 0 and 10. In your application you have expressions such as "Random(11) + Random(11) + Random(11)". This will give you a number between 0 and 30. The expression "Random(31)" also gives you a number between 0 and 30, and while it the probability of generating the numbers between 0 and 30 aren't exactly the same between the 2 equations, I doubt that you really need the differences that a longer expressions like "Random(11) + Random(11) + ..." provides. Random(31) just simplifies things a bit.

    The main problem that you are having is with your MoveSpeed variable. You are generating a number between 30 and 50 with "Random(11) + Random(11) + 30" and then dividing it by 100. Many people have trouble with issues like this. The reason it isn't working is because it is saving your resulting answer as an integer. The highest answer you will get is 50/100 which is 0.5. By default the value will round down to the nearest integer and turn 0.5 into 0. Basically, you're setting each fish's position to...

    x(Fish) + x(Difference between Fish and Active)*(0), or in other words, x(Fish) + 0

    What you need to do is divide by "100.0" instead of "100". This allows the values to have decimal answers. Instead of 50/100 turning into 0, it will actually turn into 0.5 as you anticipated. BTW, using "100.0" is way too fast IMO. I'd divide by a number closer to "1000.0" personally.

    Here's my updated version. There are definitely things I would still tweak about it, but since I'm not entirely sure what you're aiming to achieve I'll just leave it as is.
    Attached files Attached files

  3. #3
    Clicker Multimedia Fusion 2
    Wolfking_Warrior's Avatar
    Join Date
    Aug 2012
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help!
    (The reason why I had several random numbers added together was just because I had thought it might even the randomization a bit.)

    *EDIT*
    In case you're still wondering, the guide (which wasn't finished yet) was supposed to move around the screen, "pulling" fish into schools that would follow it.

Similar Threads

  1. Hungry Fish
    By SoftWarewolf in forum Android Released Games & Apps
    Replies: 1
    Last Post: 6th November 2013, 08:03 PM
  2. Making a fish?
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 26th August 2012, 06:17 PM
  3. Hungry Fish HD
    By Kisguri in forum iOS Released Games & Apps
    Replies: 0
    Last Post: 26th August 2011, 01:28 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
  •