Troubleshooting - Make Actor move to Mouse click

TheHooglerTheHoogler Member Posts: 102
edited November -1 in Working with GS (Mac)
I'll start with what I want to do, and then I'll detail what I've already done (and what seems to be happening).

I have a scene that is bigger than the camera. I want to be able to click mouse/touch (without having to hold) and have my actor move to that position (while moving the camera origin). I'm doing this for an rpg type game, so the scene will be huge. I also don't want a Dpad on an iphone, so I'm experimenting with this type of movement.

What I've done so far....

I've set up the camera offset so that I can track camera origin.
I've set up attributes that track each time the mouse is clicked.
I've experimented with mouse down/up, touch press/release, a boolean "movetrue", and a direct move to touch x/y.
I've experimented with move to and interpolate (I love interpolate, but I want my hero to move at the same speed regardless of distance)

This is what is happening...

When I click inside of the original camera zone, it works fine. When I click outside of the original camera zone, the hero moves towards that point (with camera following) but will usually continue past the point I clicked (even though its basing its movement off the registered click attributes). I'll try to describe what appears to be happening. Once I click off the original camera zone, it seems to confuse the coordinates of the click with the click in relation to screen. I set up a display text to confirm this. My scene size is 960wide. When I click on the far right of the screen, it registers my click as ~x470, but the actor moves to ~x950.

I want to be able to click on coord. x 450, and have my actor move there. When coord. x 750 is visible, I want to be able to click it, and have my actor move there.

It was kind of hard for me to articulate this problem, so hopefully its clear. Any help is much appreciated!

Comments

  • sebmacflysebmacfly Member Posts: 1,018
    Hi,

    Try to edit your actor (you want to move) in your scene (not your prototype actor)...

    In the move to, write that :

    Move to : game.Mouse.Position.X + scene.Camera.Origin.X (current scene camera origin)

    Same for Y :
    Move to : game.Mouse.Position.Y + scene.Camera.Origin.Y
    Let me know... Cheers
  • latygo60latygo60 Member Posts: 27
    Try making the movement with a change attribute and adding to the actual position the mouse coordinate tracked (that you said it was registering right).

    Change attribute "self.position" to "self.positionX+450(tracked)" & the same for Y

    This, will change the position, but to make the actor move to that position, you could make two new actor attributes 'destinationX' and 'destinationY' that are the mouse tracked position+self.posX&Y and make the actor Move to self.destinationX and self.destinationY when you touch.

    I don't know if this would work :)

    Hope it helps
  • TheHooglerTheHoogler Member Posts: 102
    @ SebMacFly

    Unfortunately, this lead to the same result. Thanks anyways.

    @latygo60

    I wasn't able to make this work. Thanks anyways.

    In playing around with this, I am unable to get GS to understand any coordinates outside of the 480X320 box. My scene is double these dimensions, so I thought I'd be able to log coordinates like 500,500, or 720, 480 etc. Does this mean GS doesn't understand a large area, or am I doing something wrong?
  • sebmacflysebmacfly Member Posts: 1,018
    TheHoogler said:
    @ SebMacFly

    Unfortunately, this lead to the same result. Thanks anyways.

    I'm doing this in my game and works perfectly....
  • sebmacflysebmacfly Member Posts: 1,018
  • TheHooglerTheHoogler Member Posts: 102
    @ Sebmacfly

    Really? I'll take a closer look then.
  • TheHooglerTheHoogler Member Posts: 102
    @Sebmacfly

    That method made my hero constrain itself to the mouse cursor. I don't want my hero to move continously. I want the hero to move to the mouse click position, and stay there unless another mouse click is register. I then tried doing the same approach with mouse.touch instead, and it replicated my original issue.
  • sebmacflysebmacfly Member Posts: 1,018
  • sebmacflysebmacfly Member Posts: 1,018
    Owww i see (i'm not using the move to, but other way)... try that :

    Have an icon to click on (move character)... that's for the game to know that you want to move your character.

    RULE : When "move icon"=1
    -Rule : When mouse button is down
    --Move to : magnitude( game.Mouse.Position.X , self.Position.X )+ scene.Camera.Origin.X
    magnitude( game.Mouse.Position.Y , self.Position.Y )+ scene.Camera.Origin.Y
  • TheHooglerTheHoogler Member Posts: 102
    I don't really understand your icon part, since I want the character to move whenever the screen is touched anywhere. I tried setting up the moving by magnitude but the hero would only move in a northeastern direction with those instructions.
  • BlackbirdStudiosBlackbirdStudios Member Posts: 493
    TheHoogler said:
    I don't really understand your icon part, since I want the character to move whenever the screen is touched anywhere. I tried setting up the moving by magnitude but the hero would only move in a northeastern direction with those instructions.

    Hi TheHoogler,

    Perhaps I can be of assistance. I made a gamesalad template that explains how to do what you are looking for.

    Untitled

    I set it up so that the actor only moves when the mouse button is down, and moves to the mouse x and y coordinates. And when the mouse button is up, the x and y of the actor are constrained.

    Hope this helps

    -Matt
  • TheHooglerTheHoogler Member Posts: 102
    Unfortunately, since the expression editor isn't expanded, I can't see what you used in the "move to" behavior. You do mention "only moves when mouse button is down"... I can do that. But that requires the user to continually press the screen in order to make the hero move, which is not what I want. I want the user to be able to click/press a location (and release) and the hero to move to that position. I have tried this same setup with mouse up as well, so its not that.

    The problem lies with GS only recognizing coordinates within the 480 X 320 original camera view. The camera offset works perfectly if you constrain the hero to the mouse, or you hold down the button. But as soon as you try to make it a press/release, it confuses the coordinates, and the hero that is supposed to go to 480, 320 actually goes to 960, 640.

    Stormy Studios has this in his top down shooter template. I've shot an email to him to see if I can dredge up any info on it.
  • sebmacflysebmacfly Member Posts: 1,018
    TheHoogler said:
    I don't really understand your icon part, since I want the character to move whenever the screen is touched anywhere. I tried setting up the moving by magnitude but the hero would only move in a northeastern direction with those instructions.

    If you want i can take a look on your project.
    Zip it and Email it to sebby_zzzz (at) hotmail (dot) fr

    Cheers
Sign In or Register to comment.