When touch is pressed, move an actor to a certain location/coordinate

Can someone explain/link me to a tutorial to do, when touch is pressed, move an actor to a certain location/coordinate on the screen. Thank you.

Chris

Best Answer

  • RThurmanRThurman Posts: 2,881
    Accepted Answer
    @mrchirs317 -- careful about rejecting perfectly good answers. That is considered very impolite. You should accept the answers given to you, and then ask for clarification.

    You will want to replace the "??" with the mouse x and y coordinates. Do you know how to put them into Change Attribute or Interpolate behaviors?

Answers

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2013

    @mrchris317 Hi, if you want to move the actor immediately to the new location:

    When touch is pressed
    Change Attribute self.Position.X to ??
    Change Attribute self.Position.Y to ??

    Or to move it over time, use either Interpolate behaviour or Move To behaviour; here's the Interpolate method, Move To is similar:

    When touch is pressed
    Interpolate Attribute self.Position.X to ??
    Duration: ?
    Interpolate Attribute self.Position.Y to ??
    Duration: ?

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • mrchris317mrchris317 Member Posts: 78
    @gyroscope thanks for the reply. Can you please explain interpolate to me if its not to much of a pain. Like when do you use it, whats its purpose, etc. Thanks.

    Chris
  • LiquidGameworksLiquidGameworks Anchorage, AKMember, Sous Chef Posts: 956
    Interpolate changes an attribute over a set amount of time. Punch in the code he showed you, and you can see it in action.
  • mrchris317mrchris317 Member Posts: 78
    For the first method, what should I input for the ??. I dont get how to make it move to the point that Im clicking. Thank you both.

    Chris
  • mrchris317mrchris317 Member Posts: 78
    Im sorry for the double post, I want to make it so when touch is pressed on the screen, the actor moves to that location on the screen. I dont know if I asked the first question right. So if my character is in the middle and I touch to his right, he walks to the location I touched, which is to the right. Please let me know. Thanks
  • mrchris317mrchris317 Member Posts: 78
    Oh I didnt realize that, I apologize. I didnt realize that, I just thought that since it said answered other forum members might think the question was answered. Sorry about that.

    If you could let me know, Id appreciate it. Once again sorry to all Ive offended and thanks for the clarification.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    No problem!

    Maybe this video from @tshirtbooth will help:
  • mrchris317mrchris317 Member Posts: 78
    Sorry watched the tutorial but since it was a bullet, I got confused. Can someone please help me with the code for when the screen is pressed, the actor moves to the area that was touched. Thanks, sorry this stuff is difficult for me to comprehend.
Sign In or Register to comment.