GameSalad

moving towards a direction in a circular pattern.

IceboxIcebox Posts: 1,363Member, PRO

Hello , I did a small animation to describe what i want cause it might be confusing from the way im saying it.

I want the black circle to move towards the red circle like the example below. This was done in flash but i want to do the same in gamesalad. The red circle moves randomly on screen and the black should follow it. I can do vector to angle to constrain the rotation of the black circle to the red circle , but i don't know how to move the black circle towards the direction of the red circle.Can Anyone tell me how to do this in GS ? to move the black circle so that it always follows the red circle. I hope i make sense.

Thanks

Comments

  • SocksSocks London, UK.Posts: 12,698Member, PRO
    edited April 2016

    @Icebox said:
    I want the black circle to move towards the red circle like the example below.

    With the new COM control this is going to be very straightforward, but for the time-being you can simply make the black circle actor a long rectangle with the black circle positioned at one end - then use Rotate to Position to track the red circle.

  • IceboxIcebox Posts: 1,363Member, PRO

    Oh I never used rotate to position before I'll check it out now thanks @Socks

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,877Member

    Com is already available to test with in the current version you will just need the pin function to handle any collisions or use gravity.

  • IceboxIcebox Posts: 1,363Member, PRO

    @Lost_Oasis_Games Yea I watched your tutorial i remember now it should work that way, , i stayed for couple of hours thinking about max and min and trying to figure out a way to constrain the black circle to the yellow circle and have it move towards the target , kept searching earlier threads until i lost it and decided to ask and im glad i did. Saved me the headache but i still want to know how to constrain its max and min position to the circle in case i use it for future purposes, but this is good for now.

  • RThurmanRThurman Posts: 2,721Member, Sous Chef, PRO

    @Icebox -- here is one way to do it with constrain behaviors:

    Constrain Attribute: self.targetAngle To: (((vectorToAngle( game.Mouse.Position.X -284, game.Mouse.Position.Y -160)+180)%360)-180)
    
    Constrain Attribute: self.PositionX To: 100*cos( self.targetAngle )+284
    
    Constrain Attribute: self.PositionY To: 100*sin( self.targetAngle )+160
    
  • IceboxIcebox Posts: 1,363Member, PRO

    @RThurman Thanks alot , it worked :)

  • RThurmanRThurman Posts: 2,721Member, Sous Chef, PRO

    You are welcome!

Sign In or Register to comment.