Help with positioning a line!

UnicornInvasionUnicornInvasion Member Posts: 301
edited March 2012 in Working with GS (Mac)
I have a character and another actor2. When actor 2 is pressed the character interpolates itself to that position. However I want a line to go in between them Here is a vid!

Comments

  • UnicornInvasionUnicornInvasion Member Posts: 301
    Bump
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited March 2012
    first make an actor to act as the line and put it in the scene

    Make 5 game attributes. 1 boolean, and 4 real. Call them showLine(boolean), targetX, targetY, characterX and characterY (real)

    In actor 1:
    -constrain characterX to self.position.x
    -constrain characterY to self.position.y

    In actor 2 have when touch is pressed:
    -change attribute showLine to true
    -change attribute targetX to self.position.x
    -change attribute targetY to self.position.y

    In the line actor have a rule when attribute showLine = true:
    -constrain self.size.width to magnitude(abs(targetX-characterX),abs(targetY-characterY))
    -constrain self.rotation to vectorToAngle(targetX-characterX,targetY-characterY)
    -constrain self.position.x to characterX+((targetX-characterX)/2)
    -constrain self.position.y to characterY+((targetY-characterY)/2)

    then in actor1 have a rule when its self position x and y equal the positions your interpolating them to, change attribute showLine to false

    cheers
  • UnicornInvasionUnicornInvasion Member Posts: 301
    Thank You! 100% Works! That was amazing help! I cannot thank you enough!
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Anytime, glad i could help.
Sign In or Register to comment.