Use two constrains

SLOCM3ZSLOCM3Z Member Posts: 797
edited May 2015 in Working with GS (PC)

Hello,

Is it possible to constrain x and y to a real attribute? I did this: "Constrain Attribute : game.Center" :to: "self.x - self.y"
But all I got were a bunch of negative numbers behind half of the screen. Can someone help me?

Thanks

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @jdlcrater said:
    Is it possible to constrain x and y to a real attribute?

    Do you mean the X and Y positions of an actor ? If so, the yes, you can constrain them to a real attribute.

    @jdlcrater said:
    I did this: "Constrain Attribute : game.Center" :to: "self.x - self.y"
    But all I got were a bunch of negative numbers behind half of the screen. Can someone help me?

    It's hard to make any kind of suggestion as there is no way for people to know what the result should be as you've not said what it was you were expecting to get, or what game.Centre is, or whether self.x and self.y are moving or static . . . etc.

  • SLOCM3ZSLOCM3Z Member Posts: 797
    edited May 2015

    @Socks. Sorry, I now know I could have been clearer. I was expecting the X and Y to be measured with one real attribute. But I guess I can't do that and I will have to do 2 real attributes.

    Thanks!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited May 2015

    @jdlcrater said:
    Sorry, I now know I could have been clearer. I was expecting the X and Y to be measured with one real attribute.

    That still doesn't really mean anything specific. :(

    Measured how? Are you trying to determine how far apart their values are? Why are you wanting to constrain an attribute's value to two different values? It's certainly possible but it depends greatly on the answer to those questions.

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

  • SLOCM3ZSLOCM3Z Member Posts: 797

    I wanted x and y to be the same thing so that I could say "when game.PlayerX & game.PlayerY" = "game.Center(portal's X and Y)" :do: whatever. But that can't work. I hope you understand that time. I have no other way of describing what I want. I was just wondering if x and y are measurable at the same time so that I don't have to make two attributes. But I am fine with doing so. I was just wondering if it is possible. I will just do "When game.PlayerX and game.PlayerY" = "game.PortalX and game.PortalY" :do: whatever

    Thanks!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You have two options:

    1. Unlock one of the actors (the player or the portal) in the scene and access the other actor's self attributes through the Current Scene-->Layers-->[layer name]-->[actor name] section of the Attribute Browser. This requires no additional game attributes but it does require creating an "instance" of the actor (by unlocking it) which means that that specific copy of the actor in the scene may have unique rules when compared to the "prototype" for that actor.

    2. Create game attributes for each actor's x and y positions as you've mentioned and constrain these game attributes to the actor's self attributes.

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

  • SLOCM3ZSLOCM3Z Member Posts: 797

    @tatiang Thanks. I have it fixed now. Sorry about my weird descriptions on how I wanted to do things. Thanks for your help!

Sign In or Register to comment.