RRandom Not adhering to Minimum Value

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • This is my first attempt at a game without following any tutorials and I chose a basic Target Shooter

    General Idea. Shoot A Target, get points, new target, repeat... Timer Runs out, game over.

    The new target is to be in a random position within the frame, however I want it to 'spawn' below a certain point (score/timer area at the time of the frame)

    Please login to see this attachment.

    ^--- should be an image showing a screenshot of the result, and the RRandom expression used.

    I thought RRandom(65, ......) would mean that the Y position of the object is placed at least 65px down, but it doesn't seem to work that way. (The rest of the RRandom Expression if you didn't work it out was to make sure that the object is fully visible within the frame (which seems to work)

    Any thoughts on what I could be doing wrong?

  • I have tried to document all of the basic actions, conditions, and expression of each of the seven default objects in MMFusion. The following is a functional description for the random functions.

    Quote from Random Function Descriptions

    The random functions generate a random number. Random generates a number from 0 ≤ x ≤ (max_number - 1) while Random Range generates min_number ≤ x ≤ max_number

    Format: Random(A), RRandom(B, C)

    Where:
    • A = Positive Integer
    • B = Integer where B ≤ C
    • C = Integer where C ≥ B

    Output: Integer

    For RRandom, you need to make sure B is less than C. So if you are using variable parameters in the function, you should do the following.

    RRandom( min(B,C), max(B,C) )


    You can find more information about other system and default actions, conditions, and expression within "Clickteam Fusion Basic Object Reference PDF" at the following tutorial.

    Link: Please login to see this link.

    • Please login to see this link.

    Please login to see this picture.

    Edited once, last by Yves (March 12, 2022 at 7:56 AM).

  • ProdigyX,

    Thank you for your response, but it didn't help me with my problem.

    I changed my usage of RRandom to include the Min/Max functions (which I didn't find necessary as I knew 65 was lower than the variable I was putting in), and I was still getting the unexpected results.

    Then I changed my usage of RRandom to constant values, and it is still not working as I want. Below is an image showing part of the screen (including title bar of the app so you can reference the top of the frame), and i've overlayed the expression placing the object in that position

    Please login to see this attachment.

    As you can see I have the Y position being set to RRandom(65, 340), so why is the object being placed at Y position 17 ???

  • I just did a simple test by placing a counter and setting it to RRandom (65, 340) every 1 second

    It works as expected which leads me to believe it's something else in your project

    The first thing that comes to mind is the hotspot. When you set the position of an object it does so according to the hotspot, so if y is set to 65 it will place the hotspot of the active at 65

    Double click your active to open the image editor and look for this

    Please login to see this attachment.

    I believe it defaults to the center of the active object but you can place it wherever you want. Keep in mind that for some features, such as some physics movements, it has to be in the middle. Also, if you rotate an active with a non centered hotspot you'll get different rotations

    [SIGPIC][/SIGPIC]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!