Less than 1 as an alterable value in a custom movement?

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.
  • How do you set an alterable value less than 1 or between numbers like 0.5 or 1.5 when using custom movements? If I put a decimal in the object doesn't move.

    Example:

    Please login to see this link.

    Here the green counter number set to 5 is just a room number so the robot only moves when the player is in that room.

    The robot moves right until it collides with the left arrow and stops, turns around then walks left until it collides with the right arrow, stops, turns and then walks right again on a loop. This is fine but setting the xpos to 1 is too fast and I need it to walk slower but any number less than 1 for the xpos value in the robots alterable values doesn't work. Why?

    The robot is not the player so it needs to move constantly with no player input (while the player is in the room, hence the counter).

    Edited 3 times, last by soopytwist (July 17, 2017 at 5:53 PM).

  • Casting vars is big problem in Fusion from my point of view. It will be fixed in Fusion 3, I think.

    You can't set a float var directly in the objects.
    The only way I found to cast it as floats, is to add an event that multiply an alterable value by a float in the beginning, for example : alterVar(activ) * 1.0
    Then, you can do math with this var as a float.

  • As Nadapp mentions, you may only have decimal variables during runtime. Specifically, you are unable to have decimal numbers in variables during edittime. During runtime within the Event Editor, however, you can force a number to be a decimal by multiplying or adding part of the number by a decimal. In short, variables may only possess decimals if some event from the Event Editor forces them to.

    + Set Alterable Value to 1.5, for example would do the trick

    Follow this link and you can get another example of this. 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:45 AM).

  • Oh, that's annoying. If I do set xpos to 1.5, for example, then the object stops moving - probably because now I'm interring with the always event for moving it:

    Always
    + [object] Set X position to X [object] + xpos [object]

    That gets the object moving from left to right (- xpos makes it go left instead).

    Then the object collides with an active, in this case an invisible arrow left and right:

    Collision between [object] and [left arrow]
    [object] Set X position to X [object] - xpos [object]
    [object] Set xpos to 0 - xpos [object]

    Collision between [object] and [right arrow]
    [object] Set X position to X [object] - xpos [object]
    [object] Set xpos to 0 - xpos [object]

    So the object moves left and right between the two arrows but the speed it set in the alterable value of xpos in the editor. If I alter this value in an event such as start of frame it causes the object to stop moving.

    How do I resolve this and still be able to have sub pixel movement?

    Also, I have another problem with the above custom movement. I only want the objects in each room to move when the player is in the room (I assume doing this cuts down on processing and memory usage because my frame is 6080 x 4560 and has around 1,000 moving objects in it at once!). So the Always
    + [object] Set X position to X [object] + xpos [object] event also has a "if counter = number". The counter changes when the player is different rooms (primarily for re-spawning but here I can use it to stop objects in that room from moving).

    The issue here is when transitioning from one room to another if timed just right - as the object hits a left or right pointing arrow and stops, re-entering the room causes the object to pass through the arrow and floats off the screen never to be seen again. If I set overlapping instead of collide then the object gets stuck on the arrow and no longer moves. In fact it just spasms.

    To resolve this I'm having to add set position events for every single object when the player enters the room. The downside to this is having to create more versions of the same objects so they can all be re-positioned individually, which means upping the total number of objects in the frame significantly.

    Here's the code:

    For the movement:
    Please login to see this link.
    Please login to see this link.

    For re-positioning the object when entering the room:
    Please login to see this link.

    It works great because it fixes any chance the object will float off but the problem is having to clone each object of the same.

  • Can't you just create the arrows after creating the object in each room ?
    It add some events but maybe it could solve your problem

    I'm not creating the moving objects in each room, they are already there. So if the arrows are destroyed when leaving the room the objects would still sail past them and off the frame even if the arrow where created when entering the room.

    Please login to see this link.

  • For entering and exiting rooms, I guess you can handle this with flags on both the player object and the arrows.

    small example :
    Please login to see this attachment.


    I'm not sure how this helps me. Great idea for teleporting though.

    The other alternative I've experimented with is having all moving objects in the entire frame destroyed at start of frame except for the room the player starts in then when the counter = 2, for example, I create all the objects needed for that room at their positions as the player enters the room. Then I destroy them again if the counter is different to 2. Not only does this solve the colliding issue but it also frees up a crap load of memory and less stuff to save when saving the frame to file (when saving the game).

    I can't see anything inherently wrong with this method. Less work for a start.

  • Yes. This works.

    Code example: Please login to see this link.
    In-editor game screen: Please login to see this link.

    I destroy the meteor objects at the start of the frame. When the player enters the room I create them (one meteor active object copied five times).
    Then I destroy the one object when leaving the room (which destroys all five). The great thing about Fusion is that it treats each object of the same individually so despite their being five of the same active objects they all move independently of each other.

    Also, in my example the meteor objects go up slow and come down fast. For other objects that just go left and right or up and down the code is simpler.

    Still got the problem of not being able to use sub pixel movement though. Although right now it's not an issue as my object movements have all been 1, 2, 3, 4 or 5.

  • I'm not sure how this helps me.

    It was a help for this issue :

    The issue here is when transitioning from one room to another if timed just right - as the object hits a left or right pointing arrow and stops, re-entering the room causes the object to pass through the arrow and floats off the screen never to be seen again. If I set overlapping instead of collide then the object gets stuck on the arrow and no longer moves. In fact it just spasms.

  • From the look of it, your sub-pixel movement won't work properly. Your object still will move at 1 pixel per frame, because Fusion can't move it in sub-pixel increments but only in physical pixels. If xpos is 0.6 it'll move it by 1. If xpos is 0.4 it'll move it by 0.

    What we often do is instead of:
    set (object) position to x(object) + xpos

    We do:
    set alterable value x to alterable value x + xpos
    set (object) position to alterable value x

    This way, the real, decimal value of xpos is safely stored in alterable value x. Fusion still only moves in single pixels, but any remainder gets saved till next time. So if alterable value x is 0.4 one frame, (object) won't move. But next frame when it's 0.8 the (object) will move by 1. The end result will be smooth-looking movement that averages out to your desired speed.

    BTW, you can embed your imgur images in the forum using [img] tags

    Please login to see this link.
    My Fusion Tools: Please login to see this link. | Please login to see this link. | Please login to see this link.

  • Nadapp
    Sorry, my wording was a bit confusing now that I've just re-read what I put. I appreciate your help but I guess it's better to see it in action rather than me uselessly try to explain it!

    Volnaiskra
    I'll give that try, thanks :). Also, last time I used [img] tags it didn't work so I've not bothered since.

    EDIT

    And still doesn't work.

  • You have to use an actual image link (with .jpg or .png on the end). The link below isn't a link to an image, but a link to a webpage, with your image, plus other images, buttons, ads, etc.

    Please login to see this link.

    But when you locate the actual image link from that (eg. right-click> copy image address) you get a real image link that you can then put in tags:

    Please login to see this picture.

    Please login to see this picture.

    Please login to see this link.
    My Fusion Tools: Please login to see this link. | Please login to see this link. | Please login to see this link.

  • You have to use an actual image link (with .jpg or .png on the end). The link below isn't a link to an image, but a link to a webpage, with your image, plus other images, buttons, ads, etc.

    Please login to see this link.

    But when you locate the actual image link from that (eg. right-click> copy image address) you get a real image link that you can then put in tags:

    Please login to see this picture.

    Please login to see this picture.

    I've just seen the down pointing triangle thing on Imgur for links, there's an option for BBCode, I think it's that one. I've always just clicked copy and pasted the link, I didn't know it wasn't a direct link to the image. I used to use Photobucket but I got sick of all the adverts and it opening new windows all the time.

  • Anyway, things seem to be going okay now. I'm (slowly) setting up create and destroy events for each room. This solves any object movement issues I've had and also means there are significantly less objects in the frame at the start and hopefully saving and loading the frame will be less buggy now that there's less stuff to save.

    However there's a couple of enemy objects in the game where using anything other than the pre-built bouncing ball movement is going to be very difficult to do with custom movements. But I'll tackle them when I get there. No doubt I'll be back on here when I do!

    I already figured out how to combine xpos and ypos values to make objects move diagonally. The thing about those more complicated objects is that they have multiple bouncing ball directions and set to follow the player - not sure how to do this, at the moment, with the same custom movements I'm using for everything else.

  • From the look of it, your sub-pixel movement won't work properly. Your object still will move at 1 pixel per frame, because Fusion can't move it in sub-pixel increments but only in physical pixels. If xpos is 0.6 it'll move it by 1. If xpos is 0.4 it'll move it by 0.

    What we often do is instead of:
    set (object) position to x(object) + xpos

    We do:
    set alterable value x to alterable value x + xpos
    set (object) position to alterable value x

    This way, the real, decimal value of xpos is safely stored in alterable value x. Fusion still only moves in single pixels, but any remainder gets saved till next time. So if alterable value x is 0.4 one frame, (object) won't move. But next frame when it's 0.8 the (object) will move by 1. The end result will be smooth-looking movement that averages out to your desired speed.

    BTW, you can embed your imgur images in the forum using [img] tags


    I can't get this to work. My enemy objects vanish off the frame.

  • What events do you currently have. It should be as simple as Always setting the X position to some variable and making change to that specified variable.

    + Always
    - Set Xposition to alterable value xpos

    + [some condition]
    - [modify value of xpos]

    • Please login to see this link.

    Please login to see this picture.

  • I can't get this to work. My enemy objects vanish off the frame.

    Try setting the xpos value to the object's current position at the start of the frame. What's probably happening is that the initial xpos value is 0, which forces it to that position.

    Please login to see this link.-Please login to see this link.-Please login to see this link.

  • Why doesn't this work? Setting an alterable value of 0.5 stops the object from moving, in this case an elevator for the player to ride up and down on.
    Anything above 1, including 1.5 seems to work (unless it's actually ignoring the .5 as I can't really tell the difference between 1 and 1.5 to be honest).

    Please login to see this picture.

    The counter 64 is a room number so when the player is in room 64 the elevator moves (it's destroyed when not in room 64 and it's created when entering room 64). When facing up I set it's Y pos to Y pos of the elevator minus alterable value of ypos (so it goes up). When facing down I set it to plus ypos (so it goes down). When the elevator hits the up arrow trigger it changes the direction of the elevator to up and when it hits the down arrow trigger it changes to down.

    This works perfectly fine and for every other object in my game but only if I set alterable value ypos to 1 or 2 or 3 etc in the editor. If I leave it ZERO and instead set the alt val to 1, 2 or 3 when the elevator hits the up/down triggers then that works too.

    What doesn't work is setting the alt val to 0.5.

    Please login to see this picture.

    I made this game in 2015 but since I wanted to update it with a game saving feature I've had to replace all objects that have bouncing ball movements with custom ones instead which means no sub pixel movement. And I had to do this because saving the frame bugs-out objects with bouncing ball movements. While everything else works just fine with ypos or xpos values of 1 to 5 or more, setting 0.5 at runtime isn't working.

    Basically I need the elevator to move slower than 1 because 1 is too fast for the player (and the player has a habit of falling through it).

Participate now!

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