how to make the actor to move up and down againg and again

ronreronre Member Posts: 38

hello,
i have actor that spawned every x time and i want him to move up and down.
i tried to do that with two timers and two "move to",
one timer: for 1, move self.position.y+1
timer two: after 1,move self.position.y-1
and all this in a timer "every 2 second".
its not working. how should i do that?

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2015

    Constrain Y position to:

    AAA * sin (self.time * BBB) + CCC

    . . . . . . . .

    AAA = how far you want your actor to move.
    BBB = how fast you want your actor to move.
    CCC = the centre point of the movement.

  • ronreronre Member Posts: 38

    hey, how exactly to do that? inside the "move"?
    and its possible to stop the actor movement in his position by clicking on the screen?

  • SocksSocks London, UK.Member Posts: 12,822

    @ronre said:
    hey, how exactly to do that? inside the "move"?

    Use a Constrain behaviour.

    @ronre said:
    and its possible to stop the actor movement in his position by clicking on the screen?

    Wrap the Constrain behaviour in a rule that says:
    When mouse button is down . . . have nothing in the rule section - and place the Constrain behaviour in the 'otherwise' section.

  • ronreronre Member Posts: 38

    thank you. when i use the constrain behavior its canceled the spawner random position.
    i mean, the spawner spawn actor in randomal "y" and the constrain behavior canceled it.
    2. the stop in the actor movement is only when i hold the click. how can i make the actor to stop his movement after click. without pressing.

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

    Here's a demo that locks into position when you click on the moving actor. It also spawns a "center" actor to show where the original position of the spawned actor was.

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

  • ronreronre Member Posts: 38

    great. thank you!!

  • SocksSocks London, UK.Member Posts: 12,822

    @ronre said:
    thank you. when i use the constrain behavior its canceled the spawner random position.
    i mean, the spawner spawn actor in randomal "y" and the constrain behavior canceled it.

    .

    @Socks said:
    Constrain Y position to:

    AAA * sin (self.time * BBB) + CCC

    . . . . . . . .

    AAA = how far you want your actor to move.
    BBB = how fast you want your actor to move.
    CCC = the centre point of the movement.

Sign In or Register to comment.