How to make straight movement between 2 actor with touch movement ?

Haris01Haris01 Member Posts: 8
edited January 2015 in Working with GS (PC)

Hi.. i want to make my actor(actor1) can move foward backward straight with touch movement between 2 actor or 2 position x,y(actor2) to x,y(actor3). I already know to make straight movement x to x or y to y. I'am new in GameSalad. Help me please..

Best Answer

  • SocksSocks London, UK.Posts: 12,822
    Accepted Answer

    @Haris01 said:
    Yes.. that image... can someone teach me how to do that ?

    Constrain X position to:

    max(100,min(800, game.Mouse.Position.X ))

    Constrain Y positon to:

    ( self.Position.X /2)+200

    . . . . . .

    Obviously you would need to play with the values to get what you need.

Answers

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291

    Hello @Haris01,

    Can you please be more specific with what you are trying to accomplish. A bit confused.

    Thanks

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    So you want the player to tap on actor2 and have actor1 move to actor2 and then when the player taps on actor3, actor1 moves to actor3? By the way, are you using a Mac or PC?

    Edit: here's a little demo made on the Mac.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Haris01Haris01 Member Posts: 8

    Sorry, make you all confuse.. what i mean is the rule more like this..

    Rule:

    When touch is : inside

    do

    Constrain attribute

    Constrain : self.position.X to max(self.Actor Min , min(self.Actor Max, game.Touch.Position.X ))

    this will move my actor min and max only in X position,

    what i need is my actor will move between min(as actor2 location) and max(as actor3 location. When i change actor2 and actor3 location, my actor(actor1) still move depend actor2 and actor3 with any angle and distance. Example, i change Actor2 in position X=0,Y=0 , Actor3 in position X=10,Y=10. so, actor1 will move in 45 degree from 0,0 to 10,10.

    Actor1 = will move with slide touch,
    Actor2 = position min or max,
    Actor3 = position min or max.
    

    One more sorry if make you all confuse. Maybe because i'm not familiar with terminology GameSalad or my english is bad..

    sincerely hope :)

  • Haris01Haris01 Member Posts: 8

    Thanks Tatiang for your little demo, I appreciate it..

    I'm using pc, nevermind if your demo made on mac..

  • Haris01Haris01 Member Posts: 8

    does anyone can help me ?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    In the demo I attached, I created two real attributes called game.targetX and game.targetY. In actor2 and actor3, If Touch is Pressed change attribute game.targetX to self.Position.X and change attribute game.targetY to self.Position.Y. In actor1, if Mouse Button is Down moveTo game.targetX, game.targetY relative to scene at whatever speed you want (I used 150).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Haris01Haris01 Member Posts: 8

    image

  • Haris01Haris01 Member Posts: 8

    i can't see an image.... this project make my brain freeze.... :#

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015
  • Haris01Haris01 Member Posts: 8

    Yes.. that image... can someone teach me how to do that ?

  • Haris01Haris01 Member Posts: 8

    That the answer..

    so.. i make new rule here...

    if
    
    my app make profit
    
    do
    
    Socks will be getting a bit...  :# 
    
  • ArmellineArmelline Member, PRO Posts: 5,364
    edited January 2015

    I made a demo for this a while ago. I'll see if I can find it.

    Edit: Found it:

    http://forums.gamesalad.com/discussion/comment/488023/#Comment_488023

  • Haris01Haris01 Member Posts: 8

    Yes Armelline, but i need your 'red actor' speed follow my finger..
    However, thank's because enlivened my question.. after 1 month headache.

    i give u (*)

Sign In or Register to comment.