Actor can be moved by player's dragging on cell phone

HLQuanHLQuan Member, PRO Posts: 10
edited January 2015 in Working with GS (PC)
  1. I have create an actor named 'Player'.
  2. When playing it on Android cell phone,I can move this actor by dragging it.
  3. But there isn't a Drag Behavior in the CS (PC).
  4. How could I make it?

Comments

  • wcsd9739wcsd9739 Member Posts: 37
    edited January 2015

    You mean you want to be able to drag it around? Try a rule like this:

    Rule: If Touch is Pressed Constrain self.position.x to game.Touches.Touch1.x Constrain self.position.y to game.Touches.Touch1.y

    Hope this helps.

  • HLQuanHLQuan Member, PRO Posts: 10

    @wcsd9739 said:
    You mean you want to be able to drag it around? Try a rule like this:

    Rule: If Touch is Pressed Constrain self.position.x to game.Touches.Touch1.x Constrain self.position.y to game.Touches.Touch1.y

    Hope this helps.

    But this is not a dragging. The actor will change its position suddenly.
    In a game named 'Sky Force', I can drag my airplane in a certain linear velocity.

  • wcsd9739wcsd9739 Member Posts: 37

    @HLQuan said:
    But this is not a dragging. The actor will change its position suddenly.

    Are you sure you used the "Constrain Attribute" behavior and not "Change Attribute"?

    And relating to your other post, if you wanted to make the actor follow the touch at a max speed, then Move To will stop functioning if the actor actually reaches the touch position. Instead, try this:


    The first rule detects if somewhere was touched (if you only want to be able to drag the actor, change Inside and Outside to just Pressed). The inner rules (X and Y Allowance) make it so the actor doesn't jitter about when it reaches the touch... change each 4 to something lower for more accuracy. And finally the Move just moves it in the direction of the touch. The second picture is of the Direction for the Move.

    There might be a better way of doing it, but this works for me. Good luck!

Sign In or Register to comment.