Problems with objects following the player

0 favourites
  • 4 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • Hi everyone! Sorry to bother, but I need help!

    Well, my intention is to develop a game where your character must collect eggs scattered at the stage and take them to a checkpoint. When you pick up one egg (by touching it), it follows you. Get another one and it will also follow you, right after the last egg you caught, making a line.

    The problem is: After getting the second egg, the first one stops following you properly, staying fixed at one point, instead of going to the correct Player fixed point (It looks like the lerp formula is being ignored somehow).

    I don't know what to do to fix it. Could you guys give me a hand?

    This is my code so far:

    <img src="http://i10.photobucket.com/albums/a126/shinobi_br/my_code_zps5f866edf.jpg" border="0" />

    And a link to play the demo:

    dl.dropbox.com/u/12937330/follow_test/index.html

    Thanks in advance!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Event 5. You check if eggsSaved=1, only then should the first egg follow the player. This is probably not what you want.

    Also, you are not doing this very efficiently. Everything you have done could be done with one object with a few instance variables. that way you won't have to repeat code. 99% of the time if you are repeating code there is a better way.

    Let me know if it doesn't work for you.

  • Event 5. You check if eggsSaved=1, only then should the first egg follow the player. This is probably not what you want.

    Also, you are not doing this very efficiently. Everything you have done could be done with one object with a few instance variables. that way you won't have to repeat code. 99% of the time if you are repeating code there is a better way.

    Let me know if it doesn't work for you.

    I thought that I had to check it in order to make the first egg properly follow the player. I would never guess it was that.

    I know it's not the best way to do this. Before this I tried to create the catching system only using one egg object, but I couldn't figure how to treat each object instance separately, so I made this way in order to produce some result before I go crazy :P. If you have any suggestions on how to do this I'd really like to learn!

    Thank you very much for your help!!

  • OK, I made some changes at the code, now using only two objects: One to be caught, then it is destroyed to be replaced by other who will follow the player.

    <img src="http://i10.photobucket.com/albums/a126/shinobi_br/my_code_zps4981de7c.jpg" border="0" />

    It is working well. But there's still a problem. the second egg caught doesn't follow behind the first egg, but follows the player, hiding itself behind the first egg.

    I'd like to know if there's a way to create events that affects a specific instance, since every change I want to make at the variables affects the object, not an specific instance.

    Thanks for the help!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)