How can I do this?

So I have an actor that is on top of the scene and it's Y position is random.

Is it possible to have another actor on the bottom that uses the top actor's Y position to determine it's own Y position?

Think if it like flappy bird. The pipes are always going up and down but the gap is always same length between the two. It's like the bottom pipes uses the top pipe's Y position to determine it's own Y position.

Comments

  • pHghostpHghost London, UKMember Posts: 2,342

    Use the top actor to spawn the bottom actor. That way it will always be a certain distance under the top actor, based on the setting of the Spawn behavior.

  • ShortAxe5ShortAxe5 Member, PRO Posts: 69

    @pHghost‌

    Thanks

  • ShortAxe5ShortAxe5 Member, PRO Posts: 69

    @pHghost‌

    How would I spawn it? Using the spawn actor rule of course

    I can't seem to get it to work

  • ShortAxe5ShortAxe5 Member, PRO Posts: 69
  • pHghostpHghost London, UKMember Posts: 2,342

    @ShortAxe5‌ -- what isn't working exactly, can you describe more?

    Here is an example, check it out, and analyze what it does differently, so you understand why your isn't doing what you want it to.

  • ShortAxe5ShortAxe5 Member, PRO Posts: 69

    The zip file isn't working for me for some reason, Ah well.

    Anyone?

  • mhedgesmhedges Raised on VCS Member Posts: 634
    edited September 2014

    @ShortAxe5,

    The cleanest way would possibly be to:

    1. have an "event handler" actor spawn both actors.
    2. Both actors would move at a fixed speed along the playfield (use a variable if you wish to speed the actors up or down),
    3. move (or interpolate) the opening between the pipes going up or down the length of the pipe at at a fixed speed (variable if you want to make it more difficult), and
    4. move (or interpolate) distance between top actor from bottom actor, fixed (or variable if you want to open or close the gap between "pipe actors"), kinda like a "chomping mouth".

    1 and 2 are a must, 3 and 4 increase the difficulty / fun factors.

    Good luck!

  • ShortAxe5ShortAxe5 Member, PRO Posts: 69

    @The_Gamesalad_Guru‌
    I'm on a pc

    @mhedges‌
    Thanks a lot! But is there anyway I could use the top actor to control the lower actor's y position instead of having something spawn them both?

  • ShortAxe5ShortAxe5 Member, PRO Posts: 69

    Bump

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited September 2014

    Unlock the bottom actor and:

    Constrain Behavior: self.Position.Y To:scene.Background.topActor.Position.Y-100

    You can change the -100 to suit the gap you are looking for.

  • ShortAxe5ShortAxe5 Member, PRO Posts: 69

    Ok thanks again guys!

Sign In or Register to comment.