Making a direction controller

IntelligentDesignerIntelligentDesigner Member Posts: 517
edited November -1 in Working with GS (Mac)
I am making a directional controller, and have an integer attribute called "game.direction" When "UP" is pressed I make it 12, "DOWN" is 6, "RIGHT" is 3, and "LEFT" is 9, (like a clock).

I have an actor that I want to control with this controller, so I added a rule to that actor that runs if the game.direction = 12, etc. As soon as the button at the controller is pressed ("UP" in this example) I get uncontrolled "UP" movement (not like when the keyboard "up" key was pressed, nicely moving one unit at a time.)

I have the same rule reset game.direction attribute to 0 in the same logic that does the UP.

How can I get one and only one "UP" per touch on the controller? I want it to behave like the keyboard did, one step per click...

Thanks in advance for any suggestions, GSers...

Comments

  • Rob2Rob2 Member Posts: 2,402
    if you use Move To rather than Move and then a small amount relative to the actor wont that do it?
  • IntelligentDesignerIntelligentDesigner Member Posts: 517
    Might, but I am moving via spawning a new actor above me, so as to leave a trail...

    Thanks for the thought though...
  • IntelligentDesignerIntelligentDesigner Member Posts: 517
    Anyone got a thought about this? Seems like it should work.
  • VoidedSkyVoidedSky Member Posts: 1,095
    directional controller with the keyboard keys?
  • IntelligentDesignerIntelligentDesigner Member Posts: 517
    Directional controller without the keyboard keys. Keyboard keys do not work on iPhones only in GS Web Apps. (I think) That's why I want to use a directional controller.
  • VoidedSkyVoidedSky Member Posts: 1,095
    I will try to get u a demo in the morning or sometime tomorrow if none of the other great GSers don't help.
    Good luck
  • IntelligentDesignerIntelligentDesigner Member Posts: 517
    Thanks, CowTechMan!

    I am still working at it, thinking perhaps it is a timing issue, and maybe a timer pausing it till the attributes have a chance to reset themselves may help...
  • VoidedSkyVoidedSky Member Posts: 1,095
    Hi, This way that I will show you will be different than what you are doing now.
    Attributes: game.up game.down game.left game.right

    now, I am assuming you will have 4 actors for the arrow keys for touch.
    I will name them Left, Right, Up, and Down

    Here are the rules for them:
    Left
    --- Rule; when actor recieves touch change attribute game.left to true
    -----Otherwise; change attribute game.left to false

    Right
    --- Rule; when actor recieves touch change attribute game.right to true
    -----Otherwise; change attribute game.right to false

    Up
    --- Rule; when actor recieves touch change attribute game.up to true
    -----Otherwise; change attribute game.up to false

    Down
    --- Rule; when actor recieves touch change attribute game.down to true
    -----Otherwise; change attribute game.down to false

    -----------------------------------------------------------------------------------------------
    Now this code is for your actor/player/movable object;

    --Rule; when attribute game.up is true accelerate up (I'm not on my mac so I'm not sure what the angle is off the top of my head)

    Now do this for all of the other attributes game.down, game.left, and game.right

    I think this should work.

    If it doesn't work, then do this in the player movement for the arrow keys: --Rule; when attribute game.up is true accelerate up (I'm not on my mac so I'm not sure what the angle is off the top of my head)
    ----(added part) Otherwise accelerate up at ZERO speed

    Hope it works!!
    ~CTM
  • IntelligentDesignerIntelligentDesigner Member Posts: 517
    Thanks, CowTechMan, but this would only work if I am moving via a Move or MoveTo action. As I mentioned at the beginning I am trying to move via spawn, so as to leave a trail. The process of moving works perfectly well when tied to the keyboard, but when you swap the attributes check from "actor receives keystroke UP" to "attribute game.direction = UP" the movement is okay, but the trail cannot be contained.

    Previously I had a rule that if the length was exceeded, to destroy the oldest actor, as measured by his ActorID. This logic no longer works when the control is switched to touch, instead of keyed.

    Can anyone help to explain why?
  • IntelligentDesignerIntelligentDesigner Member Posts: 517
    Anyone? There must be a way to easily substitute a control pad for the keys. Again, the code works when the keys are the basis for the rules. As soon as the control is taken from the control pad/joystick object, the movement still works but the length logic is never invoked. WHY?

    Remember: in this case the actor is moved my SPAWNING,*not*
    Move or move to.
  • IntelligentDesignerIntelligentDesigner Member Posts: 517
    Can anyone from Gendai help with this bug?
  • Rob2Rob2 Member Posts: 2,402
    can you not post a project? I mean its hard to understand, one touch is one touch just like one key press, whats going wrong?
  • IntelligentDesignerIntelligentDesigner Member Posts: 517
    yes, you would think so...

    apparently there is a huge bug here.
Sign In or Register to comment.