Direct Variable Access

Andre87Andre87 Member Posts: 42
edited November -1 in Working with GS (Mac)
Hey guys, Im new to GameSalad, and I came across a problem while experimenting.
Is there a ways to change an attribute of one actor directly through another actor. That is, is there a behavior
I can add to an actor that would change an attribute of another actor?

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    To control the attribute of one actor threw another you need to make a global variable for it, and depending on what you want to do you need to constrain something.

    Say you wanted actor 1 to control actors 2 color, for an example well use when you touch actor one, you want actor 2 to become invisible, then reapeear when you release.

    So you would make a real attribute and call it actor2color, and then set it to 1 since thats its original state(alpha)

    In actor 2 add a constrain attribute and constrain self color alpha to actor 2 color.

    Then in actor one have when touch is pressed change attribute actor2color to 0.

    That will then cause actor 2 to become invisible becaause its color is constrained to actor2color attribute that you made.

    Then in actor one have another rule when touch is released change attribute actor2color to 0

    So long story short since actors 2 color is constrained to the global attribute actor2color you made, you can now change its color threw any actor by simply having a change attribute behaviors and changing actor2color you made
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Also, an unlocked Instance can control another Actor - as well as everything in the Scene - directly. However, if you are just starting out, I recommend doing what John says.
  • Andre87Andre87 Member Posts: 42
    I was aware of the you described John, before I posted. But thanks a lot anyway for trying to help. I really appreciate it. This is why I am asking for a "direct" way to access and control variables of one actor with another actor. The method of making variables global to access it with another actor is very tedious.

    "Also, an unlocked Instance can control another Actor - as well as everything in the Scene - directly"
    So if there is a method for doing this, please tell me. I may be a beginner to GameSalad, but I am programmer. So I think I can handle it :D.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    When you make a actor then drag it into the scene, its a proto type of the actor you made in the actor pane. All the rules you put in that actor in the pane will apply to all the actors of that kind dragged onto the scene. So if you make a actor put all your rules in it and then drag 5 of them into the scene, all 5 of them will have the same behaviors as the one in the actor pane, and whatever behaviors are put in the one you made in the actor pane will apply to all 5 of them in the scene.

    When you diuble click the actor thats actully dragged into the scene, and not the one you made in the actor pain, a screen will pop up with a lock. Thats staying its locked and that all it rules are controlled by whatever rules are in the original one in the actor pane. If you then click on the lock, it will unlock it and then youll see the are where you can add your rules and behaviors. Once its unlocked changes in the original actor in the actor pane wont effect the unlocked actor in the scene, and to change its rules u have to click onthe actual actor you unlocked in the scene and add them there.

    Also like firemaple said when an actor is unlocked, and you add a change or constrain attribute behavior in the unlocked actor, and then go into the attribute browser youll see a extra list in the drop down that says current scene (you only scene that in unlocked actors) You can then get to every actor in the scenes attributes,(so the position, color, ect of every actor in the scene) as well as scene attributes which include camera position and rotation.

    But say you control one actor, or the camera or somethign like that threw a unlocked actor, and happen to forgot which one you did that too and then want to delete the behavior, youll have to check every actor in the scene of that type till you find the right one. Theres also some other issues you can run into.
  • Andre87Andre87 Member Posts: 42
    "Also like firemaple said when an actor is unlocked, and you add a change or constrain attribute behavior in the unlocked actor, and then go into the attribute browser youll see a extra list in the drop down that says current scene"

    Riiiiiiiight. Got it man. Thank you soooo much :D.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    anytime, glad you got it working
Sign In or Register to comment.