Enemies with gravity

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.
  • I've been trying to do enemies that jump around the play area. When it comes to wall detecting, I've been trying to avoid making sensors, and the results have been glitchy. Now then, when I try to use sensors, I spread value A of the sensor and the enemy to make each have a separate ID. However, if I try to make an event with 'if value A of sensor = value A of enemy', it bugs totally, and A) can't find the sensor or B) the event affects to every enemy in the play area at the same time.

    Does any of you have any examples or other kind of help for doing enemies with gravity?

  • In my experiences, it's bugging because the conditions are calling different objects. If you're not looking for accelerated gravity, it's rather easy. If you are, then you're going to need a detector (because of the way groups work and can't call themselves).

    Basic premise is this:

    -Spread value over object (or group)
    -Always:
    --Start loop 1 for # of object times
    --On loop + loop index = value
    ---Start loop 2 X times (X is fall speed in pixels)
    ---On loop 2 + value = loop 1 index
    ----Move down 1 pixel
    ---On loop + object over background
    ----Move up 1 pixel, stop loop 2

    That should make it work.

  • Wow now that looks imaginative! I've never thought it could've been done that way! :D
    ...But however, I need accelerated gravity. I think I didn't say it clearly in the first post, but I can accept movements with sensors, I'd just like an example on how to get the sensors and the whole movement WORK with ,any enemies at the same time. :)

  • You can do that too. Just have a variable for vertical speed and start loop 2 as often as that value.

    If you increase that variable every frame / interval, you have increased falling speed.

    <span style="font-style: italic">&quot;I'm not saying you don't know what you are talking about, but I don't know what you're talking about.&quot;</span>

  • it gets more complicated to do this actually, because instead of using the object to do the collision detection, you need to position a detector under it. Set it's value to the value of the objects, and use that to call the object within the conditioning. Or just position it below the object and use the loop index before to move them together.

    You might need to add an infinite loop before loop 2 that you can stop, so that way it'll cycle through all of 1. Let me know if it works!

  • Quote from pirodaggar

    it gets more complicated to do this actually, because instead of using the object to do the collision detection, you need to position a detector under it. Set it's value to the value of the objects, and use that to call the object within the conditioning. Or just position it below the object and use the loop index before to move them together.

    You might need to add an infinite loop before loop 2 that you can stop, so that way it'll cycle through all of 1. Let me know if it works!

    Well, I've been trying to do this with sensors, but if I spread the ID values of the enemies and the sensors, and try to make them recognize each other with those ID's it bugs. Basically an event 'IF value A(enemy) = value A(sensor)' doesn't work.

  • So use the loop index of loop 1, position the detector under it and during a falling loop just move the two independently (again using the loop index of 1 to pick the object out of the group) until detector hits something.

    Also, I believe it needs to be value a(sensor) = value a(enemy), and if that still doesn't work its because your conditions are negating out the objects.

    The way conditions work for things like groups is every action affects the group until they aren't part of a condition, then they are removed from the action-affect list. This caused a lot of problems for me in the past so I would just be aware of that.

  • You can make use of MMF's oddity, that it always matches up objects of which the same amount exists. So if you have 20 enemies and 20 sensors they match up. Search the forum for this, there's a nice thread explaining it better.

    On the other hand that is pretty silly for sensors. Just use one sensor, loop through all enemies and position it to the current one, one at a time. If you need different shapes for different directions, you can either use a different object per shape, or animation frames/directions for each shape.

    Even better, don't use any sensor. You can check against the collision mask of the frame and see if there's an obstacle at a given X/Y position. Then you don't need any extra objects. Just check at as many positions around the enemy as you need (e.g. twice under it, left and right bottom and top, above, in the center).

    So. There's three doable solutions (I've used all of them in the past and they all work). The last one is the fastest and most reliable one (even if you check many pixels (e.g. 20)), unless you need really odd shaped sensors or need to check against other objects. Then the second solution is better. The first one is just for when you don't know any better :P

    <span style="font-style: italic">&quot;I'm not saying you don't know what you are talking about, but I don't know what you're talking about.&quot;</span>

Participate now!

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