object follows player with delay

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.
  • Hi, I use PMO, an invisible rectangle is what defines the movement of the player sprite, I simply say "Always set position (0,0)" to my player sprite, all that is perfect.

    My question specifically, I would like a second sprite to follow the movements, with a brief delay. For example, something similar to what happened in Sonic 2, with Tails following Sonic (I don't need him to try to find new paths, just repeat the player's movement but with a delay). Any suggestions on an easy way to achieve this?

    Please login to see this attachment.

  • I don't have much knowledge of MMF2, what you mention about the list, is it done with the array object? Do I save the position at 0?

    Always: Please login to see this attachment.

    and then... to my sprite, I tell it to load its position from the array like this?

    Always: Please login to see this attachment.

    I guess I'm doing something wrong (or very wrong), I certainly don't see my second sprite even on screen.

  • You could set it to the 1st sprites position rather than the array. See if that makes a difference.

    ** Opps that's not going to work - sorry I couldn't help.


    It's going to be a challenege to record the players movement, and have the second player use them exactly, but with a delay. I managed to get a player reverse all its movements. I made a game called 'Feed Me'. I think I recorded the movements using global values and then reversed them when the player needed to back track.

    Please login to see this link.

  • I would take another approach rather than a list:

    when you move and therefore set the position of the main sprite, create also that second sprite at the same position.That second sprite should have an alt. value, say "alphaValue". Set that value to 0.

    Always: add 1 to that alt. value.

    Always: set the alpha ( transparency ) of each created second sprite to the value of its alt. value "alphaValue".

    Always: if the alt. value "alphaValue" of any second sprite is greather than 255 then destroy it

    You can play with the alt. value and the condition and so adjust the "life" of the trail.

    Or you can use another alt. value as a "appear delay", and when that delay value is zero, you can show the trail sprite. That way the trail sprite would appear a bit far away of the main sprite, thus obtaining a similar effect as shown in the .gif you posted above.

    I hope it makes sense for you.

    Regards,

    Sergio

  • Well, it seems that it was more complex than I assumed, so I think I'll use a simpler alternative solution (simply add a few more pixels in X to each sprite, even if they always remain displaced).

    I have tried to do this solution that Sergio gives, I don't know if I didn't do it right, but it didn't turn out the way I wanted. Although I will continue thinking about that idea because I think it should work (I tried copying XY values as alteredValues and then adding and subtracting them every 5ms, and positioning the object according to those values but I haven't been able to do it well either, but I think it could be... ), but for now, I will stick with what I said in the previous paragraph xD (which was what I was already using).

    Anyway, thanks everyone!

Participate now!

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