How to make one actor react when another is touched?
brettw777
Member Posts: 24
I am asking this to the good people of the forum because I am afraid Tatian is gonna get tired of me soon!
I thought this was going to be quite easy when I thought it up but being new to Gamesalad...I guess not. I have a spotlight and its beam as two separate actors. I want the beam to appear as soon as the spotlight is touched. Here is what I did so maybe someone can tell me where I went wrong. Also, I want the beam to be at .4 alpha.
Beam actor's alpha is at 0 to start. Not sure about that either.
2. created boolean game attribute called beamOn
3. For the beam actor, I have attribute -game.beamOn is true, change attribute self.color.alpha to .4
For spotlight actor that is to be touched to launch the beam:
1When touch is pressed
2. Attribute game.beamOn is false
3. Change attribute game.beamOn to true
I have tested it several (okay many) different ways and sometimes the beam is already on the minute I start the scene. Anyone...please? Thanks!
I thought this was going to be quite easy when I thought it up but being new to Gamesalad...I guess not. I have a spotlight and its beam as two separate actors. I want the beam to appear as soon as the spotlight is touched. Here is what I did so maybe someone can tell me where I went wrong. Also, I want the beam to be at .4 alpha.
Beam actor's alpha is at 0 to start. Not sure about that either.
2. created boolean game attribute called beamOn
3. For the beam actor, I have attribute -game.beamOn is true, change attribute self.color.alpha to .4
For spotlight actor that is to be touched to launch the beam:
1When touch is pressed
2. Attribute game.beamOn is false
3. Change attribute game.beamOn to true
I have tested it several (okay many) different ways and sometimes the beam is already on the minute I start the scene. Anyone...please? Thanks!
Comments
https://www.dropbox.com/s/ns6i0zt6tuk1tzb/Spot Light.zip
Create an object. Have it display and constrain to a variable game.Diagnostic1.
The object repsonsible for changing game.beamOn, have it also "constrain game.Diagnostic1 to game.beamOn"
This will show you if beamOn is working. If it is, try "logging" another variable, such as self.color.alpha. (Just remember to turn off the original code that constrains beamOn to diagnostic1) Perhaps self.color.alpha is working fine, but for some reason, it isn't being displayed correctly. "Log" all variables involved to see where the code may have went wrong.
Here is the update. Zweg, I followed your behavior guidelines. I did not change the behaviors of the beam that was already in the scene but did change the prototype. That did not work. I then added those same behaviors to the actor beam in the scene and it worked perfectly. I cannot figure out why my prototype beam actor does not change the behaviors of the actor already set in the scene. I don't know if there is a glitch in my GS program or if I am misunderstanding how this is supposed to work. I have just begun making my game and I was under the impression that when the prototype actor's behavior is changed, all of the actors of that prototype change too. Either way, I figured it out and got it working. Thanks again!
Make sure the actor on the scene hasn't been unlocked. That's really the only reason that an actor wouldn't behave according to its prototype rules. That or if it depends on the value of a self attribute and that attribute's value has been changed manually on the actor on the scene but not on the prototype actor (essentially giving it an "instance value").
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User