Pixel By Pixel Custom Platform Movement, a Bad Idea?

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.
  • Was going to attempt to make a custom platform movement for another game concept I was thinking of, but without using extensions since in my experience, they tend to crash.

    I came up with something that moved the player one pixel at a time, though via Fastloops, so that if it collided with a wall, it'd be pressed up against it instead of being several pixels off. (As in, if it's moving at a speed of 5 pixels per frame, and it collides with a wall, the Fastloop will have it stop against the wall instead of 4 pixels away).

    Now I'm also wanting to do that for enemies eventually, but I got to thinking. Would that kill performance if I put a bunch of enemies' movements in a bunch of Fastloops while also within For Each loops as well? Or is there an easier, extension-less example out there that'd have that kind of pixel precision?

  • This is entirely possible and as long as coded properly would have no great impact on performance. I use custom fastloop (with ForEach) movements for all of my game elements from playable characters and enemies to projectiles. There are a lot of examples in these forums and around the net. Search for "pixel perfect collision detection" here or on google to get started, but it sounds like you're on the right track. The biggest trick is limiting how often loops run and there are a variety of solutions for that around here.

  • So I went with your advice. We'll see how things perform later on when there's lots more objects to deal with. I managed to make a player and enemy movement nearly identically (and pretty quickly too considering my experience these days!), and it's pretty much loops within loops to have it work. Thank you. :)

    I'll need to look around a bit more though, for a way to add in platform code that you can pass through from below, and things like moving elevators/platforms and slopes to act right.

  • A bit late, as I've been busy lately, but I finally got around to watching that tutorial and implementing it. It works great, thank you! Now at the moment, it's not working for multiple enemies simultaneously, but I'll figure that out later. Or I'll make them not able to pass across sloped surfaces, maybe.

    Now I'm looking for moving platforms and elevators and the like. If you know where I could find examples of those, I'd greatly appreciate it. :3

    EDIT: To clarify, I got it working fine for a player, but I think it's because there's only one instance of the player for the fast loops to worry about.

  • Yeah, using this method (FastLoop movement) for multiple enemies is a little tricky. You gotta go with For Each Loops. Hopefully someone here can explain it better because I'm a bit confused about how it's done myself.

    Edited once, last by Edel (February 10, 2020 at 7:54 PM).

  • Yeah, using this method (FastLoop movement) for multiple enemies is a little tricky. You gotta go with For Each Loops. Hopefully someone here can explain it better because I'm a bit confused about how it's done myself.

    If you want the precision and speed of fast loops for multiple objects you can use a ForEach loop to trigger a scoped fast loop. Scoping is how you tell Fusion which object to affect when there is more than one copy. What you do is start a ForEach loop called something like "EnemyMovement" for your Enemy object (you can always run this ForEach, but if you don't need to it's best to figure out how often you do and avoid an "always" event).

    On that ForEach loop you need to do two things:

    1. You need to either use a global value or create an active object to hold an alterable value. This value will be called something like "ScopedEnemyID." On the ForEach loop you will FIRST set this value to the fixed value of your Enemy object. Fixed values are unique to every object created in the game, so this number will tell Fusion the unique identifier of whatever object you are scoping without you having to create one yourself.

    2. In the same event (but AFTER you set the ScopedEnemyID value to the Fixed value) you then start a fast loop called something like "EnemyFastLoopMove."

    Now you can trigger all of your movement code individually on each object, instantly, by simply using your code but with "On Loop "EnemyFastLoopMove" , AND "ScopedEnemyID = Enemy Object Fixed."

    What is happening is that the ForEach loop, one by one, picks one of your enemy objects, sets it's fixed value to the currently scoped value, and then runs a fast loop for just that object. It does this over and over for every one of those objects. Fast Loops can not, on their own, be scoped to specific objects. So without the ForEach loop, the fast loop will run every event that mentions the Enemy object for every Enemy object and you'll get some very weird results. I hope that helps.

  • Thank you for explaining this for me. It makes sense but I can't get it correctly. Could you be kind enough to fix this for me: Please login to see this attachment. So that I can see how it's done. You create an enemy by left clicking but it's not scoping properly when the enemy touches the player all the enemies move at the same time.

  • I cleaned some things up for you. This should be a bit more efficient. I don't have enough time to work on my own projects let alone others, so I won't be able to do much more, but I hope this helps. Please login to see this attachment.

  • Running too many loops and not keeping scope as narrow as possible can result in strain on the engine if you have too many objects at once, but everything in this gif is running using fast loops. From the player to the enemies, and every bullet and the particle effect generators and even the destructible terrain, and it stays at 60 fps (the gif is recorded at 33fps). (ignore the attachment, it's a jpeg, lol)

    Please login to see this link.

    Oh, and the yellow enemies are all using dynamic pathfinding and line of sight detection as well.

  • Tried clicking some of these examples to see how the code looks (with assigning a FastLoop with a fixed ID capture inside of a ForEach loop), but it won't let me download it. Just says "attachment.php" and doesn't go anywhere from there.

Participate now!

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