How to set actor B runing around actor A

HLQuanHLQuan Member, PRO Posts: 10
edited December 2014 in Working with GS (PC)

Here's what I want to do:
1. Actor A can be moved by the player's dragging.
2. The player cann't moved actor B directly.
3. Actor B is to run clockwise around actor A.
4. These two actors will never be at the same point.
5. With the Behaviors listed in the library, I could only set actor B rotating itself but not going around another actor.

Best Answer

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

    @tatiang said:
    It sounds like you just want actor B to orbit actor A.

    There's a demo here but it's for the Mac. On that page, though, it lists the expressions:

    100cos( self.Time *-200%360)+ game.sunX
    100
    sin( self.Time *-200%360)+ game.sunY
    vectorToAngle( game.sunX – self.Position.X , game.sunY – self.Position.Y )

    You don't really need the %360 part or the vectotToAngle calculation, more simply actor B could use:

    Constrain self.x to 100 *cos (self.Time *-100) + actor A.x

    Constrain self.y to 100 *sin (self.Time *-100) + actor A.y

    Constrain rotation to (self.Time *-100)

    (P.S I still think it's disaster that the forum software removes certain asterisks from posts . . . to people new to the forums and GameSalad many expressions posted, that contain asterisks, are rendered useless by the fact that the forum puts the importance of being able to embolden text in a forum post above being able to communicate a multiplication !)

Answers

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

    Put these two behaviors in Actor B:

    Rotate to Position: >= ActorA.x,  ^= ActorA.y, Offset Angle= 90, speed= 500, relative to scene
    Move: Direction= 0, relative to actor, move type additive, speed= 100
    
  • HLQuanHLQuan Member, PRO Posts: 10

    Like this? It doesn't work. ——I'm from China.您会说中文吗亲 :D

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

    It sounds like you just want actor B to orbit actor A.

    There's a demo here but it's for the Mac. On that page, though, it lists the expressions:

    100cos( self.Time *-200%360)+ game.sunX
    100
    sin( self.Time *-200%360)+ game.sunY
    vectorToAngle( game.sunX – self.Position.X , game.sunY – self.Position.Y )

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

  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2014

    ..

Sign In or Register to comment.