Help with Rule

B1984B1984 Member, PRO Posts: 91
I'm trying to get a turret to rotate when a game attribute is true.

Steps taken:

Created a game attribute Boolean "RB"
Created a button, rule= Touch is pressed, change game attribute "RB" to true
Turret rule= If game attribute "RB" is true, then Rotate counter clockwise


Seems simple right? But it's not working... the turret has zero physics and is movable, the background that it on has zero physics... I'm puzzled and I know it's something simple that I'm just overlooking. Any help appreciated, if not... I'm sure I'll figure it out with 3-4 more cups of coffee.

Comments

  • FallacyStudiosFallacyStudios Member Posts: 970
    Have you verified that when the button is pressed that it is turning RB to true? Place a display text in one of your actors and link it to RB to make sure it is changing properly.
  • B1984B1984 Member, PRO Posts: 91
    Fallacy, good call with the text. The boolean is not responding to the touch or arrow command.
  • FallacyStudiosFallacyStudios Member Posts: 970
    That is generally how I find bugs. Just track it back until it doesn't go any further. The result generally being, that is the actor causing the issue.

    Is this button a toggle button? When you press it one time it makes it false and another time true? Do you have it set for on Touch Release? If not done properly, those can be a pain in the butt and not function as you would expect.
  • B1984B1984 Member, PRO Posts: 91
    Yes, it's a toggle and a pain. My plan is that the turret will rotate when the player presses a button it turns the boolean to true else the boolean is false and the turret is not rotating.

    Something so simple, but kicking my butt and this is the easiest part about this experiment.
  • FallacyStudiosFallacyStudios Member Posts: 970
    So while the button is pressed it rotates and if you release the button it stops?

    Have you tried 2 rules? One with Touch Pressed making it true and one with Touch Released setting it false. If that doesn't work properly you can always have it be Constrain Attribute to True while Pressed.
  • B1984B1984 Member, PRO Posts: 91
    For test purposes I just want the turret to rotate if I press the button and then stop rotating if I release the button. later, I'll need the button to turn the boolean to true and stay true until the button is pressed again.

    I don't know... I can't seem to get the button to change the game attribute boolean to true once in game. I can start it as true, then when I click it stops but that's the end of the run. Maybe I'll try an integer.
  • FallacyStudiosFallacyStudios Member Posts: 970
    edited March 2014
    Boolean should work fine for this purpose. If the end result you want anyways is for it to toggle on and off with each press then do this.

    Rule: If Touch Pressed
    Rule: If RB True
    Change Attribute RB False
    Otherwise
    Change Attribute RB True

    The second rule is inside the Touch rule and the true Attribute change is the otherwise of the second rule.
  • B1984B1984 Member, PRO Posts: 91
    Yup, tried that and a few more crazy ideas. Nothing changes the game boolean to true. I can turn true to false once, but that's it; I can't change it back to false.

    This is driving me crazy because it's such a simple thing and it doesn't work. Game booleans can be toggled, right?
  • B1984B1984 Member, PRO Posts: 91
    I finally figured out a way that works for me, I had to add a timer that would change the boolean to false every .01 seconds. Now my turret rotates on one command.

    Thanks for the brainstorming, Fallacy.
Sign In or Register to comment.