how do i attach an actor to another actor?

how can i make an actor stay on top of the postion of my moving actor? or stay within a certain position of an actor thats moving?

Comments

  • wpatenwpaten Member, PRO Posts: 281
    2 Actors:
    your_actor_1_leading
    your_actor_2_following

    You need 2 Scene Attributes (Both Real)

    your_actor_x
    your_actor_y

    In the actor that you want to lead, you will need a constrain behavior

    constrain (scene.your_actor_x) to (self.position.x)
    constrain (scene.your_actor_y) to (self.position.y)

    In the actor you want to follow you will also need a constrain behavior

    constrain (self.position.x) to (scene.your_actor_x)
    constrain (self.position.y) to (scene.your_actor_y)

    That's it.
  • SocksSocks London, UK.Member Posts: 12,822
    Actor 1 is the moving actor, actor 2 is the following 'satellite' actor.

    Make two game attributes:
    MasterPosition X
    MasterPosition Y

    In actor 1 place two constrain behaviours:
    Constrain MasterPosition X to self position X
    Constrain MasterPosition Y to self position Y

    In actor 2 place two constrain behaviours:
    Constrain self position X to MasterPosition X
    Constrain self position Y to MasterPosition Y
  • AdamgoproAdamgopro Member Posts: 310
    @socks @wpaten thanks guys really helped!

    socks had a feeling you was going to be quick on the scene at answering this haha!
  • SocksSocks London, UK.Member Posts: 12,822
    @socks @wpaten thanks guys really helped!

    socks had a feeling you was going to be quick on the scene at answering this haha!

    Not quick enough ! 8-X
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    @Socks - *Bum bum bum* - not enough cups of coffee, eh? ;)
  • SocksSocks London, UK.Member Posts: 12,822
    @Socks - *Bum bum bum* - not enough cups of coffee, eh? ;)
    No, the wine ran out on my intravenous set up.
  • wpatenwpaten Member, PRO Posts: 281
    I'm just trying to get up to my 100th post. :D
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    edited February 2013
    @Socks - Hate it when that happens. I'll keep you in my thoughts. ;) :bz I need one of those for my Dr. Pepper. ;)
  • AdamgoproAdamgopro Member Posts: 310
    @socks ok i have managed to do what u said is it possible to keep actor 2 in the same position as actor 1 but slightly lower in a different place?
  • AdamgoproAdamgopro Member Posts: 310
    edited February 2013
    edit
  • wpatenwpaten Member, PRO Posts: 281
    edited February 2013
    constrain (self.position.y) to (scene.your_actor_y)-10

    or whatever number you want it lowered by.
  • SocksSocks London, UK.Member Posts: 12,822
    Damn you wpaten !!!

    [shakes fist at sky] /insert sound FX: Thunder. 8-X
  • SocksSocks London, UK.Member Posts: 12,822
    @Socks - Hate it when that happens. I'll keep you in my thoughts. ;) :bz I need one of those for my Dr. Pepper. ;)
    I normally have a boy who changes my wine for me, but his family were wiped out in an avalanche so I gave him a couple of hours off.
  • SocksSocks London, UK.Member Posts: 12,822
    @socks ok i have managed to do what u said is it possible to keep actor 2 in the same position as actor 1 but slightly lower in a different place?
    Basically what wpaten said.

    Here's some constrain stuff I coincidently posted yesterday in the 'spare code' thread: (there's an offset just like you want in there)

    http://www.mediafire.com/?9fld3cme7oc7d3o
  • wpatenwpaten Member, PRO Posts: 281
    Damn you wpaten !!!

    [shakes fist at sky] /insert sound FX: Thunder. 8-X


    =)) You have no idea how many times I have played out that joke here at work. Ahhhhh sweet childish humor...how I love thee.
Sign In or Register to comment.