Making 2 actors move up and down in relation to each other

umeiumei Member, PRO Posts: 21
I am trying to move 2 actors up and down in sync. I tired constraining the y position of the obstacle by using AAA*cos(self.time*BBB)+CCC

What do I do so that actors are in sync with each other?

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Create two real attribute: Call one Actor1X, the other Actor1Y.

    In your first actor:
    Constrain attribute: game.Actor1X to self.Position.X
    Constrain attribute: game.Actor1Y to self.Position.Y

    Of course, you'll have some way to move this actor in here.


    In your second actor:
    Constrain attribute: self.Position.X to game.Actor1X
    Constrain attribute: self.Position.Y to game.Actor1Y
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    well cheater's way is to constrain the postion Y of actor 2 to the position Y of actor 1.

    then you just have to worry about making actor 1 move.
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    well cheater's way is to constrain the postion Y of actor 2 to the position Y of actor 1.

    then you just have to worry about making actor 1 move.
    ... :((
  • umeiumei Member, PRO Posts: 21
    @Braydon_SFX‌ @jonmulcahy‌ Thanks for your help. I got the actors to move up and down continuously with a constant gap in between. The problem I am having now is that when I spawn these actors they do not move. These 2 actors move on the screen to the left. I have a move behavior in both of my actors. Basically I want these actors to move left and also move up and down.

    If I just drag these actors on the scene and preview they do move however.
  • umeiumei Member, PRO Posts: 21
    @Braydon_SFX‌ @jonmulcahy‌ Any idea? I spent 2 hours but can not figure this out. The movement works if I just drag the actors it doesn't work with the spawn.
  • SocksSocks London, UK.Member Posts: 12,822
    "Making 2 actors move up and down in relation to each other'

    Is this a copulation thing ? :-B
  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2014
    @Braydon_SFX‌ @jonmulcahy‌ Any idea? I spent 2 hours but can not figure this out. The movement works if I just drag the actors it doesn't work with the spawn.
    You say that you tried AAA*cos(self.time*BBB)+CCC, but you offer no further details, I take it this method didn't work for you ? Are you able to say how it didn't work ?
  • umeiumei Member, PRO Posts: 21
    I am making a flappy bird type game with up and down moving obstacles. I got the actor1 to move by

    change self.motion.lin.vel.y to +40

    rule if attribute self.position.y is greater then 280
    change self.motion.lin.vel.y to -40

    rule if attribute self.position.y is less then 40
    change self.motion.lin.vel.y to +40

    Then I did what Braydon said to constrain actor2 y position to actor 1 y position with some gap in between. These 2 actors scroll on the screen right to left. So when I spawn these actors I do not get any up and down movement.
  • SocksSocks London, UK.Member Posts: 12,822
    I am making a flappy bird type game . . . . .
    :((

    (joking ;) )
    with up and down moving obstacles.
    The easiest way would be to use AAA*cos(self.time*BBB)+CCC . . . . like this:

    image
  • umeiumei Member, PRO Posts: 21
    @Socks‌ I got the up and down movement to work no problem. If I put my obstacles on screen and preview they go up and down. However, they don't move at all when I spawn them.

    My obstacles spawn every 2 second and I have a move behavior in them to move them left. It seems like I can not use move behavior with the up and down motion. Is their a limitation to the move behavior? Essentially the obstacles should move to the left while moving up and down.
  • SocksSocks London, UK.Member Posts: 12,822
    @Socks‌ I got the up and down movement to work no problem. If I put my obstacles on screen and preview they go up and down. However, they don't move at all when I spawn them.

    My obstacles spawn every 2 second and I have a move behavior in them to move them left. It seems like I can not use move behavior with the up and down motion. Is their a limitation to the move behavior? Essentially the obstacles should move to the left while moving up and down.
    https://www.mediafire.com/?9m2976vv8y2bq6d
Sign In or Register to comment.