How would You do it? Moving Actor and constraining it to spot

Hi GS peeps,

Here's what I'm try it to achieve.

IF player 1 is clicked and Village 1 is clicked THEN move player 1 to village 1. Howver Player 1 also needs to know if its near enough to move to a certain Village check image >>

!

BUT WHAT IF you have more than 1 player? like this

Cheers :) between is there a way to reward people on the forum if they help you?

Comments

  • TosanuTosanu Member, PRO Posts: 388

    This will require a table. Each player will need an integer attribute for their ID, called here IDAttribute. They will then need to have their coordinates constrained on a table at Row IDattribute. When you click on the player, a game attribute called something like ActivePlayer should be set to the player's IDAttribute. Then, when the village is clicked however you derive the distance should use, again, the Table, with Row Activeplayer.

  • wilsongaluchowilsongalucho Member Posts: 180

    Hi @Tosanu, thanks for your repply :) , hmm still not sure how this would work..

    So I have to create a table with with Players IDAtributes (or IDAttributes would go on the actor itself?)

    Then on the table I have the player coordinates constrained to IDAtributes (but whos IDAtributes the Villages?)

    Then create game attribute and which ever player I select will change that atribute to their IDAttribute. ( BY THE WAY THIS WAS VERY HELPFUL THANKS FOR THIS ONE :D because now gamesalad will know which player i'm selecting, and gave me an idea, if I create new players I will need Player count, so when new player is created, player IDAttribute will be 1+ Number of players Attribute :D ) i've tried it and it works

    However, still not sure how to constrain the players coordinates to the villages.. :S

    And how the player would know if its too far or not..

  • BBEnkBBEnk Member Posts: 1,764

    If you actually have to touch each actor before they move you could just simply check distance with magnitude by feeding each actors X,Y to a attribute.

  • wilsongaluchowilsongalucho Member Posts: 180

    Hey > @BBEnk said:

    If you actually have to touch each actor before they move you could just simply check distance with magnitude by feeding each actors X,Y to a attribute.

    Sounds like a simple solution, how would you do that? :D

  • BBEnkBBEnk Member Posts: 1,764

    heres a example I did not notice you was on PC but I think you can just rename project if not let me know and I will make screen shots.
    All it does is first gets both X,Y of Player and village and displays distance between the two and if you touch another Village it will give new distance and if you touch another player it will give distance between that player and last village touched, and ETC on and on.

  • wilsongaluchowilsongalucho Member Posts: 180

    Hey @BBEnk :D thanks for the project file test, it works great, calculating the distance, I've added player ID like @Tosanu told me to do, so when clicked on a player, Game.PlayerSelected changes to Player ID, and players move position to villages (only done to one village) So it works like this, example >When clicked on village_1 , IF Distance between Player and Village_1 is 143 , then change game.Player Move to true .. then on the player theres a Rule saying, IF game.Player Move is true and IF game.PlayerSelected = self.player ID then move Player Position x,y to Village_1 Position x,y :D

    However.. Player should not move when Village is selected then the Player.. it sould only move when Player is selected first THEN the village.. and also when selecting Player 2, then Village 1 the distance is to far so it doesnt move THATS CORRECT.. however as soon as you selected player 1 it moves straight ahead.. I've tried creating like another game attribute Village ON/OFF..in different ways but it didnt work..

    I've attached the file dunno if u can open it.

    Thank you guys for your great help :D

  • wilsongaluchowilsongalucho Member Posts: 180

    for some reason doesnt let me upload the file... :neutral_face:

  • wilsongaluchowilsongalucho Member Posts: 180

    http://www.filedropper.com/distancetestandid .. I've tried downloading from the link and it should work fine

  • BBEnkBBEnk Member Posts: 1,764
    edited September 2014

    @wilsongalucho‌

    I removed your player ID you don't need that and just added a rule that checks distance to see if it can move "300 max", So if you touch player first and then village it will show distance first then you have to touch player again to make him move, if you touch village first then player will go ahead and move if within 300 distance.

    I also put the Village rules in a void touch rule so touch is ignored when player is on top.

  • BBEnkBBEnk Member Posts: 1,764

    I miss read above heres what I think you want, had to use dropbox something up with GS.

    https://dl.dropboxusercontent.com/u/58782733/distTest3.zip

  • wilsongaluchowilsongalucho Member Posts: 180

    Hey @BBEnk thats really great! Thank you so much for your help! I still need to work on a few bits, but almost perfect I like the fact that the players move, and they are not allowed to move to Villages where the other player is ;). In effect what I'm trying to create, I don't know if you ever played, but its like Lord of The Rings Battle for Middle Earth 2, War of the Ring Mode, where you have a map and you can move troops into different territories.

    btw are you from London by any chance?

  • BBEnkBBEnk Member Posts: 1,764

    Never played Lord of the Rings, and I'm in United States.

  • wilsongaluchowilsongalucho Member Posts: 180

    Alright no worries, thank you once again for your help!

Sign In or Register to comment.