How to set actor B runing around actor A
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
-
Socks London, UK.Posts: 12,822
@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
100sin( 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
Put these two behaviors in Actor B:
Like this? It doesn't work. ——I'm from China.您会说中文吗亲
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
100sin( 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
..