adding a player to follow the other player

0 favourites
  • 8 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • https://www.dropbox.com/s/kg3z2174yrr9d ... pe%29.capx

    so, i have a few bugs and i cant seem to fix them, i want to have 2 players, when im using one the other follows, and so on, whats happening is i can only use one player, and when i switch to the other one it begins to follow the one im not using... i know the events are wrong but dont know what to do to fix them.. please help

  • I am looking at it now. When I get done going over it, I will try to post an updated version with it working for you. That being said, I noticed 1 thing that will probably help you get a little further. You are disabling the platform input on the deselected character, but you are trying to use the simulate platform button pressed to move it. If the input is disabled, you cannot use the input to move it. That is why the monster is not following when the human is active.

  • I am looking at it now. When I get done going over it, I will try to post an updated version with it working for you. That being said, I noticed 1 thing that will probably help you get a little further. You are disabling the platform input on the deselected character, but you are trying to use the simulate platform button pressed to move it. If the input is disabled, you cannot use the input to move it. That is why the monster is not following when the human is active.

    yes i noticed im disabling it so its normal that it doesnt move, but i just dont know what else to do, so i left it like that.. hope you can help me

  • Ok, I have cleaned up your events and have it doing what (I think) you want it to do. I also duplicated your monster follow events to make some equivalent human follow events. This may not be what you want, it is just to show you the setup works both ways. You can find the capx attached.

    A couple notes:

    I noticed you had a couple every tick events as sub events. An every tick event which has any other conditions is redundant. Read this page to get more information:

    https://www.scirra.com/blog/141/common- ... nd-gotchas

    I also noticed, your events to change which player is selected were set up in a way that they were firing every tick. With small project, you wouldn't notice, but as your project grew in complexity, it could really bog it down. I added an event at the start of layout to disable input on the monster and moved all of the events to switch which is controlled as sub-events to the space bar event. That ensures they only fire when you want to change users, not every tick.

    I noticed a scroll to event at the end which, because of your camera seemed redundant. I am not sure why it was there. If there is a reason I don't know about, you will want to add it back in.

    I gave the camera the ability to follow the monster when it is the selected character.

    Finally, because you were using the lerp function to move the camera, I figured the easiest method to move the follower would be to use the same method. I figure if you know enough about it to use it, what I did should make sense to you.

    As a bonus, I decided to help you cut down the number of events by 1 more. Where you set the selected value, you were adding 1 to the value. Then, in a separate event, you were checking to see if the value was above 2. If it was you were setting it to 1. This method works perfectly and is a good way to make this kind of change but eats up another event unnecessarily. So, I threw in a function you can use in your future projects. The method is "whichcharacter = 2 ? 1 : 2". This is a very simple if/then statement and can be used any time you have 2 possible results. This is what it means:

    whichcharacter = 2 -> If whichcharacter is equal to 2

    ? 1 -> Then return 1

    : 2 -> If not, return 2

    Because I wrote the function in the action to set whichcharacter, the result is, whichcharacter is set to the return value. So, if whichcharacter is currently 2, whichcharacter is set to 1. If not, it is set to 2.

    Well, that was a long one but I hope it helps. Good luck with your project.

  • Ok, I have cleaned up your events and have it doing what (I think) you want it to do. I also duplicated your monster follow events to make some equivalent human follow events. This may not be what you want, it is just to show you the setup works both ways. You can find the capx attached.

    A couple notes:

    I noticed you had a couple every tick events as sub events. An every tick event which has any other conditions is redundant. Read this page to get more information:

    https://www.scirra.com/blog/141/common- ... nd-gotchas

    I also noticed, your events to change which player is selected were set up in a way that they were firing every tick. With small project, you wouldn't notice, but as your project grew in complexity, it could really bog it down. I added an event at the start of layout to disable input on the monster and moved all of the events to switch which is controlled as sub-events to the space bar event. That ensures they only fire when you want to change users, not every tick.

    I noticed a scroll to event at the end which, because of your camera seemed redundant. I am not sure why it was there. If there is a reason I don't know about, you will want to add it back in.

    I gave the camera the ability to follow the monster when it is the selected character.

    Finally, because you were using the lerp function to move the camera, I figured the easiest method to move the follower would be to use the same method. I figure if you know enough about it to use it, what I did should make sense to you.

    As a bonus, I decided to help you cut down the number of events by 1 more. Where you set the selected value, you were adding 1 to the value. Then, in a separate event, you were checking to see if the value was above 2. If it was you were setting it to 1. This method works perfectly and is a good way to make this kind of change but eats up another event unnecessarily. So, I threw in a function you can use in your future projects. The method is "whichcharacter = 2 ? 1 : 2". This is a very simple if/then statement and can be used any time you have 2 possible results. This is what it means:

    whichcharacter = 2 -> If whichcharacter is equal to 2

    ? 1 -> Then return 1

    : 2 -> If not, return 2

    Because I wrote the function in the action to set whichcharacter, the result is, whichcharacter is set to the return value. So, if whichcharacter is currently 2, whichcharacter is set to 1. If not, it is set to 2.

    Well, that was a long one but I hope it helps. Good luck with your project.

    are you god? thanks a lot, it is so much better and easy now, i learned a lot from what you did just now, you have my thanks.sorry for any trouble you went to make this masterpiece. <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">D

  • >

    > Ok, I have cleaned up your events and have it doing what (I think) you want it to do. I also duplicated your monster follow events to make some equivalent human follow events. This may not be what you want, it is just to show you the setup works both ways. You can find the capx attached.

    >

    > A couple notes:

    > I noticed you had a couple every tick events as sub events. An every tick event which has any other conditions is redundant. Read this page to get more information:

    > https://www.scirra.com/blog/141/common- ... nd-gotchas

    >

    > I also noticed, your events to change which player is selected were set up in a way that they were firing every tick. With small project, you wouldn't notice, but as your project grew in complexity, it could really bog it down. I added an event at the start of layout to disable input on the monster and moved all of the events to switch which is controlled as sub-events to the space bar event. That ensures they only fire when you want to change users, not every tick.

    >

    > I noticed a scroll to event at the end which, because of your camera seemed redundant. I am not sure why it was there. If there is a reason I don't know about, you will want to add it back in.

    >

    > I gave the camera the ability to follow the monster when it is the selected character.

    >

    > Finally, because you were using the lerp function to move the camera, I figured the easiest method to move the follower would be to use the same method. I figure if you know enough about it to use it, what I did should make sense to you.

    >

    > As a bonus, I decided to help you cut down the number of events by 1 more. Where you set the selected value, you were adding 1 to the value. Then, in a separate event, you were checking to see if the value was above 2. If it was you were setting it to 1. This method works perfectly and is a good way to make this kind of change but eats up another event unnecessarily. So, I threw in a function you can use in your future projects. The method is "whichcharacter = 2 ? 1 : 2". This is a very simple if/then statement and can be used any time you have 2 possible results. This is what it means:

    >

    > whichcharacter = 2 -> If whichcharacter is equal to 2

    > ? 1 -> Then return 1

    > : 2 -> If not, return 2

    >

    > Because I wrote the function in the action to set whichcharacter, the result is, whichcharacter is set to the return value. So, if whichcharacter is currently 2, whichcharacter is set to 1. If not, it is set to 2.

    >

    > Well, that was a long one but I hope it helps. Good luck with your project.

    >

    are you god? thanks a lot, it is so much better and easy now, i learned a lot from what you did just now, you have my thanks.sorry for any trouble you went to make this masterpiece. <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">D

    but i found a problem, you see i wanted to only gain character 2(monster) when i press my E near the ovo object, but when i do that, it created a totaly diferent character, so when i press space my camera goes to the character 2(which is out of the way, meaning..in the blank space where i cant see him) instead of the new spawned object

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I would have to see the capx to get an idea of what is going on.

    [EDIT] NVM, I see what you mean on the version I already have. Looking into it now.

    [EDIT] OK, that was an easy fix. I added a variable called, "MonsterExists" 0 for false and 1 for true. I destroyed the off screen monster on start of the layout (you could also just move this monster into view instead of destroying and recreating but this took the fewest steps to get your current set up working) and I added a few actions to your create event including setting MonsterExists to 1 and moved the monster disable action into this event instead of the start of layout.

  • yes, its perfect now, again, my thanks.

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