Grab and hold

I am trying to make actor 1 grab and hold onto actor 2. I tried using a constraint attribute with actor 1 to say that when it collides with actor 2, constrain its x and y position. That didnt work though. How would I go about doing this?

Comments

  • ookami007ookami007 Member Posts: 581

    Let's say you want actor player to hold onto actor sword.

    Create 2 game attributes called playerX, playerY

    In your player actor, constrain playerx = actor.position.x, and likewise with y. So basically, you are constraining the game attributes playerx and playery to the player actors x and y, whatever those are.

    Next, in the sword actor, create a attribute called pickedUp and set it to false

    On collission with the player, have the sword actor set pickedUp to true

    now, just add a IF attribute pickedUp = true, then constratin sword.position.x to playerX and sword.position.y to playerY.

    That SHOULD do it... since I just did exactly that really quickly and it worked. :wink:

  • GamingtilDawnGamingtilDawn Member Posts: 104

    Thank you very much @ookami007! That helped me out.

  • ookami007ookami007 Member Posts: 581

    I created a quick template for you using the Mac version.

    It has a player you can move with the left and right with the A & D keys. There are two keys... a blue on which is built on the rule above and a yellow one which will change direction with the player as he's holding it.

    I hope it helps.

    https://dropbox.com/s/rr6vd32ldsh89e0/Item%20Pickup%20Sample.zip?dl=0

  • GamingtilDawnGamingtilDawn Member Posts: 104

    Great Demo! @ookami007 Thank you again!

  • ookami007ookami007 Member Posts: 581

    @GamingtilDawn said:
    Great Demo! ookami007 Thank you again!

    My pleasure. I hope it helped.

Sign In or Register to comment.