how to pin an actor on top of another actor

In my game i have a tank and a separate actor for the gun when the tank moves it leaves the gun in its spot. How do i keep the gun attached to the tank?

Jarritos

Comments

  • ArmellineArmelline Member, PRO Posts: 5,456

    Make game attributes for the X and Y positions of the tank (and rotation if you want the gun to move with it).

    In the tank actor, constrain these X and Y game attributes to self.position.x and self.position.y.

    Then on the gun actor, constrain self.position.x and self.position.y to the X and Y game attributes.

    Do the same for rotation if you want that constrained too.

  • JarritosJarritos Member Posts: 23

    That just made the gun disappear.

    Jarritos

  • JarritosJarritos Member Posts: 23

    i fix the disappear thing but it still doesn't work

    Jarritos

  • ArmellineArmelline Member, PRO Posts: 5,456

    @Jarritos said:
    i fix the disappear thing but it still doesn't work

    Jarritos

    In what way doesn't it work?

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited June 2014

    @Jarritos In future, please don't make duplicate threads in different Forums - it's against the rules, and can cause confusion.

    (I've deleted your duplicate thread).

    BUMP:

    @Armelline said:
    In what way doesn't it work?

  • JarritosJarritos Member Posts: 23

    when i do what u told me my gun disappears

    Jarritos

  • JarritosJarritos Member Posts: 23

    thx gyro

  • ArmellineArmelline Member, PRO Posts: 5,456
    edited June 2014

    Since I'm not really sure what you're trying to accomplish, or why what I suggested didn't work, take a look at the example below. It is a tank with very basic movement and a gun attached that moves with it but swivels independently (towards the cursor).

    Note that in order to keep the gun centrally located on the tank, rather than use any fancy maths I just made the gun empty space bigger. This means the gun itself could not be used to detect collision, only the tank. Fancy maths could do the same job if that's important to you.

    Refresh the page if the attachment doesn't show up.

  • JarritosJarritos Member Posts: 23

    when i try that it only does it one time then stops i have constrained attributes

    Jarritos

  • ArmellineArmelline Member, PRO Posts: 5,456

    Please post screenshots of the rules you are using.

  • freezestudiosfreezestudios Member Posts: 3
    edited June 2014

    jorritos go to layers and make another layer and uncheck scrollable and drag the gun actor to the non-scrollable layer. if your tank does not controll the camera, this will not work.

  • JarritosJarritos Member Posts: 23

    image
    image
    ok here they are
    Jarritos

  • JarritosJarritos Member Posts: 23

    sorry freeze this did not work for me, but thanks for your help anyway

    Jarritos

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

    @Jarritos said:
    sorry freeze this did not work for me, but thanks for your help anyway

    Jarritos

    There is no need to place the two constrain behaviours within the 'every 0 seconds' timer.

  • JarritosJarritos Member Posts: 23

    ok socks thx

    Jarritos

  • JarritosJarritos Member Posts: 23

    image this is what is happening

    Jarritos

  • JarritosJarritos Member Posts: 23

    at the very begining it is doing this
    image

  • ArmellineArmelline Member, PRO Posts: 5,456

    All of your images are showing as broken for me.

  • JarritosJarritos Member Posts: 23

    thats weird socks could see them maybe this will work
    image

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @Jarritos said:
    thats weird socks could see them maybe this will work

    Can you see the images you have put in your posts ?

  • JarritosJarritos Member Posts: 23

    no socks and don't know why

    Jarritos

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

    @Jarritos said:
    no socks and don't know why

    It's pretty safe to say that if you can't see the images in your posts then no one can. I expect your image links aren't properly formatted.

  • JarritosJarritos Member Posts: 23

    ok. I don't know how to post screenshots if that didn't work.

    Jarritos

Sign In or Register to comment.