How to reference actors from others?

I'm new to GameSalad (only a week or so) and I find myself struggling with the concept of getting actors/objects to communicate with one another after checking their conditions. I used to do a lot of game development in Flash so I may be getting to focused on how I'd do it there...

What I'm trying to accomplish: I have a Hero, multiple Triggers, and an Enemy. I want the Hero to interact with a Trigger to "arm" it. I then want the Enemy to check if the Trigger is armed or not. Based on that, it might have an affect on the Enemy.

What I have so far:
1.) Actions on the Trigger that says if it collides with the Hero, set a boolean attribute I created within that Trigger to "true".
2.) On the Trigger actor itself, I have a rule that states if it collides with the Enemy and its trigger value is true...then I'd like it to do something to the Enemy (by default all the Trigger values are set to false). It's my assumption at this point, I want to put a Change Attribute into the Rule and change an attribute of the Enemy (say it's health or color or position), yet in the drop downs that come with that behavior, the Enemy isn't listed? Only Game, Device, and the Trigger Actor)

The flipside to that would be to put the rule on the Enemy and say "if you collide with a Trigger, and it's attribute is set to "true" then change an attribute within the Enemy. In that scenario I have no idea how to access the attribute of that specific Trigger (I see Game, Device, and the Enemy Actor). So it's kind of the same problem.

Hopefully that makes sense. Again I'm fairly new to GameSalad so any tutorial or "go read this" would be grateful. I've tried searching but not sure what to search for really.

Thanks!

Comments

  • mesaticusmesaticus Member Posts: 51
    Okay based on a little more research I found this solution:
    http://forums.gamesalad.com/discussion/24219/can-you-make-an-actor-reference-another-actor-s-attribute

    But that seems like a nightmare if I have a lot of triggers. It means I have to edit each instance? Ugh. Also, if there are a lot of these triggers and "Constrain Attributes" rules, how does that effect performance?

    If there is a better solution, I'd love suggestions.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited August 2013
    Use game level attributes. Those type of attributes can be accessed from any actor.
  • mesaticusmesaticus Member Posts: 51
    Thanks FryingBaconStudios. I appreciate the response.

    I'm still trying to wrap my head around terminology and how this software works and organizes things esp when placed in the game area. Coming from an OOP background I assume my master Trigger Actor has certain properties and each instance of that Trigger that I place in the game can be uniquely tweaked? Aren't Game Level attributes considered more global variables? Would I have to create a unique game level attribute for each trigger?

    I know for instance in Flash I could just replicate the main Trigger Actor and name it, say "Trigger1, Trigger2" etc and it was easy to track and change each of those unique instances. I'm not really getting that that is possible in GameSalad unless you break it from the prototype.

    Hopefully that wasn't a ramble. Thanks for any help and clarification you can provide.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    I would just duplicate the prototype in the pallet and make new names this will keep the code inside intact and then use overlap and collide and be specific to the naming convention. Not really following you on what you have going on. But yes game level attributes are for global data.

    As to you question of a prototype on the scene being customized without breaking the prototype. Check out this video I have on just that,



  • mesaticusmesaticus Member Posts: 51
    @FryingBaconStudios Thanks for sharing that video. That was actually really helpful and useful. I think it helped me clarify t that what I'm trying to accomplish isn't possible without breaking the prototype though?...which is going to be painful. Hopefully this is just a newbie mistake still.

    My example:

    Lets say I have 3 boxes in order from left to right and all have a boolean set to false. The player avoids box 1, collides with box 2, and avoids box 3. Because of the players collision, box 2 boolean is now set to true.

    An enemy comes along and collides with box 1. It's false so it no effect. The enemy collides with box 2. It's true so it affects the enemy in some way.

    Placing the rules on the boxes with the interaction with the player are easy enough. Those booleans work fine.

    Placing the rules on the boxes with interactions of the enemy are a different story. It seems like if I want to affect the enemy in some way (say it's position), I have to access scene level attributes to get to the enemies properties, which break my box prototype. (for example get the enemies current position and subtract 100)

    My next steps are just having the enemy/box collider change a global attribute value (and maybe have the enemy always look for those changes?). Not sure, still experimenting. But then of course I have to reset that attribute for the next box.

    I should say my current protoype works just like I want...just seems like a nightmare if I need to update those boxes as your example video stated.
  • mesaticusmesaticus Member Posts: 51
    If I do a game level attribute for each box it seems like that would be a massive amount of checking the enemy has to do.
  • mesaticusmesaticus Member Posts: 51
    @MlabApps @FryingBaconStudios You're both geniuses, I think it finally just clicked with me. A game level boolean attribute. If the hero triggers it, it gets set to true. When the enemy checkes for that, it either takes a hit or it doesn't, but either way, it resets the value back to false. Of course now I wonder if I'm stringing a lot of these triggers really close to each other will there be a "hiccup" with the switching that value on and off so rapidly, but for now, it works perfect and I can stick to keeping my prototypes!

    Thanks again!
  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    Isn't it a great feeling when that moment of "I get it!" happens? And then you suddenly realize all the possibilities with just that one simple function.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Ah been learning unity which is way more complex. I spent last summer learning JavaScript and the interface and did one tutorial. Still felt lost and had to fight that feeling of being overwhelmed. Reminded myself of oaky experience with GS it was a year before I knew I could figure out anything I wanted to do myself and even tackle stuff not though of yet. After completing a bunch of projects I started unity again about a month ago and now the lights are coming on. It's those moments that keep you going and believing you can learn it.
  • mesaticusmesaticus Member Posts: 51
    @FryingBaconStudios Ah, I think I was a little more of the opposite. I've spent some time in Unity before coming here. Definitely way more complex, but the interface and such really clicked with me (I used to be a Flash Dev so Unity reminded me of that, only with a 3D stage). I know ActionScript, which is similar to JavaScript, but my struggle was digging thru their API to find the right syntax for what I was wanting to do. In that way, I just felt I was wasting a lot of time. Now, that could just have been my patience. :) I think with the goal of strictly wanting to do a 2D platformer type game, Unity wasn't the right tool for the job anyways.

    I worry a tad how complex I can get with this drag-n-drop approach thru GameSalad, but so far, I'm able to get way past where I was at with Unity, in just a matter of a few days. I really can't wait to stress test stuff with graphics now to see how things perform. In a few weeks I hope to get the dev license so I can do that :)

    I know this software is still in beta, but I also can't wait for the little things (I'm sure I'm joining the list of others). Stage Zoom, Rulers, Alignment options, snapping, maybe asset libraries you can actually organize with folders, etc...I really miss those in this software.

    Thanks again for your help.
Sign In or Register to comment.