Contrain a set of actors to the movement of one "main" actor.

tippedchairtippedchair Member Posts: 3
edited April 2014 in Working with GS (Mac)

Hey there GS community. My name is Rocco and this is my first post on the GS forums. There is some really great people here and I can't believe how knowledgeable and helpful everyone is. Coming previously from a studio atmosphere this a breath of fresh air.

My question is in regards to containing actors together with tables.

I have a "main hero" the is controlled by the player. His X,Y is being a relayed to a global attribute lets call "Hero Value X and Hero Value Y".
"Companion hero's" are to shadow his movement. The X is fine because I know I want them to be offset -100.
Since I'm working in 100 pixel chuncks I know I want the "Companion hero's" Y to be constrained +100, 0, and -100 from the "main hero"s Y. The problem is the "Companion hero's" need to be pulled at random from a table.

I saw Tshirtsbooth's video on picking random values from a table. I set the +100, 0, and -100 to the table and I've applied it to the order of the Companion hero's in a value called "CompanionValue".

Companion #1
Change Attribute:
Change Attribute: self.CompanionValue To: random(1,tableRowCount( game.Table 1))
Remove Row:
Table : Table 1
Action: Remove Row: At Index self.CompanionValue

Constrain Attribute:
Constrain Attribute: self.Position.Y To: Hero Value Y + CompanionValue

In this case lets say +100 was picked from the table. I would want the Companion to be located +100Y from the Main Hero.
What ends up happening is the Companion is always locked into the 0 (middle) spot and never is offset. I through a display text to see if the table is working and I can call all of them.

Is there another way?

Best Answers

  • tatiangtatiang Posts: 11,949
    Accepted Answer

    If you log or display the value of self.CompanionValue, what shows up? Is it the value you're expecting from the table?

    You wrote:

    Change Attribute: self.CompanionValue To: random(1,tableRowCount( game.Table 1))

    But for it to work correctly, you'd need to take the tableCellValue, not the random integer value between 1 and the number of rows. I think you're confusing the CompanionValue with the rowNumber. Try tableCellValue(game.Table 1,random(1,tableRowCount( game.Table 1)),1)

    That last value in the tableCellValue() expression is the column number, so adjust as needed.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Posts: 11,949
    Accepted Answer

    You're welcome! :smiley:

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Answers

  • tippedchairtippedchair Member Posts: 3

    Thank you VERY MUCH tatiang!
    Another great example of the GS community, quickly solving something that has been bugging me for the last 24 hours.

Sign In or Register to comment.