Pin to Image Point?

0 favourites
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • I'm trying to have my character be able to lift and carry objects around (and eventually set them down). I had it working where when the player overlapped the object and pressed a button, the object would be pinned to the player. I'd like to use an image point to control the location of the object in the animation. For example, place the player's image point on his hand and have the object stick to it.

    I see a set position/angle feature that allows you to choose the Image Point, but can't find anything similar in the Pin Behavior. Any help is appreciated.

  • Make sure the object has the PIN behavior attached to it first.

    Then you should have an event like:

    Player presses (Pickup button) = > pin object to image at image point 0

  • I don't think there's an option for that under Pin. Once you pin to object, it really only lets you select the mode (position, angle, rope, etc). If there's no easy way, I may create a blank sprite at the image point and then pin the objects to that.

  • You just need to set the object's position to the image point before you pin it.

  • You just need to set the object's position to the image point before you pin it.

    That's working for lining up the object first, but I need it to follow the image point in other animations. Its basically lining itself up with the image point in the default pose and then pinning it there. When I switch animations, it still stays in the position from the image point on the default frame.

  • What the Pin behaviour does is pretty much just

    + Every Tick

    • Set [object] position to (X,Y)

    Except that the X, Y coordinates doesn't update after the object is pinned.

    If you need more precision, I suggest dropping the Pin behaviour and do it manually, using a boolean or a string value as a state machine to check when the object is grabbed or not.

    + [object] Grabbed = true

    + Every Tick (adding every tick here is not really necessary, but old habits die hard :P)

    • Set [object] position to (imagepoint.X, imagepoint.Y)

    You're doing almost the exact same thing as the Pin behaviour, but the object will follow the image point, since we are using the image point's coordinates directly.

  • I'm afraid I'm really lost. I have conditions set up for the player being over the object (orange box), a variable to check if the player is already holding an object, and what I think is a boolean checking if the box is being held. Then the player should just press the S key to pick it up.

    Problem is there is no option to check anything every tick to adjust the position. I can just assign the position, but without the "every tick" function, it just pops to where the image point was on the first frame and stays there.

    I've attached my capx file and would appreciate and help on figuring this out. I'm kind of lost. Thanks.

    http://dl.dropbox.com/u/56104169/PinTest.capx

  • sman118 I'm not sure if this is what you wanted.. but could give it a try anyway:

    dl.dropbox.com/u/33370253/PinTest_.capx

  • aruche that is AWESOME and exactly what I needed. Problem is that I'm trying to set the object down and any code I try to figure out isn't working. I'm trying to toggle the carrying off and have it end up at the player's image point and left there on the stage.

    I really appreciate the help. Also, if you could friefly explain what you did, that would help me learn it for next time. Thanks!

  • aruche that is AWESOME and exactly what I needed. Problem is that I'm trying to set the object down and any code I try to figure out isn't working. I'm trying to toggle the carrying off and have it end up at the player's image point and left there on the stage.

    If you're doing what I think you're doing, you have similar setups for the events for turning carrying on and off. Problem with this is that they will toggle in order.

    This order of events:

    + Player presses S

    + Carrying = false

    • Toggle Carrying

    + Player presses S

    + Carrying = true

    • Toggle Carrying

    It's first going to toggle the Carrying variable, but instantly afterwards it's going to toggle it again, because the conditions for that event have now become true. This will give the appearance that it doesn't work and you can't pick up the item, while in reality you're picking it up and immediately putting it down. If you reverse the order you'll have the opposite problem, you can pick the item up, but you can't put it down.

    I really appreciate the help. Also, if you could friefly explain what you did, that would help me learn it for next time. Thanks!He's effectively doing what I wrote in my post.

  • > aruche that is AWESOME and exactly what I needed. Problem is that I'm trying to set the object down and any code I try to figure out isn't working. I'm trying to toggle the carrying off and have it end up at the player's image point and left there on the stage.

    If you're doing what I think you're doing, you have similar setups for the events for turning carrying on and off. Problem with this is that they will toggle in order.

    This order of events:

    + Player presses S

    + Carrying = false

    - Toggle Carrying

    + Player presses S

    + Carrying = true

    - Toggle Carrying

    It's first going to toggle the Carrying variable, but instantly afterwards it's going to toggle it again, because the conditions for that event have now become true. This will give the appearance that it doesn't work and you can't pick up the item, while in reality you're picking it up and immediately putting it down. If you reverse the order you'll have the opposite problem, you can pick the item up, but you can't put it down.

    > I really appreciate the help. Also, if you could friefly explain what you did, that would help me learn it for next time. Thanks!He's effectively doing what I wrote in my post.

    So are you saying that there's no way of setting the object back down? Maybe I should look into destroying the object and spawning a duplicate where I want it set down. It might even be easier to attach a sprite object containing all of the objects you would carry to the player. That way I could just give the illusion of holding it. Thoughts?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So are you saying that there's no way of setting the object back down?

    Nope, just that getting it to work will need some finagling. This issue hasn't come up for me personally, so I haven't tried to solve it for myself. So currently I have no real solution to give.

    Maybe I should look into destroying the object and spawning a duplicate where I want it set down. It might even be easier to attach a sprite object containing all of the objects you would carry to the player. That way I could just give the illusion of holding it. Thoughts?

    It's certainly something you could do. However, it would have the same problem as before, just replacing carrying/putting down with destroying/creating. The problem lies with the keyboard object running every event in sequence.

    There was a discussion not too long ago about a very similar subject, and I think Ramones had a solution to the issue. http://www.scirra.com/forum/using-one-button-and-variable-to-switch-states_topic58648.html?KW=

    Not sure if that capx is still available though.

  • Couldnt open your capx ...using r109

    Anyway, try the following capx-

    download

    Good luck

  • Figured it out! At least I think I did. So I went and followed the steps that chrisbrobs used to pin the object to the player at the image point. Problem is, it wouldn't follow the image point as it updated through the animations.

    So to fix that, I created a sprite (that will be invisible during play) that would update its position every tick to be at that specific image point that I wanted. Then, instead of pinning the object to the player, I pin it to the sprite that is updating to be on the image point. I still have to do more testing, but so far its working great.

    Thanks for everyone's help!

  • Here's my take at it:

    prr-PinTest-01.capx

    As far as I remember using state conditionals as sub-events of a press button used to evaluate just one of the options for this kind of situation, but for some reason it doesn't work that way anymore.

    Something like:

    +On S pressed

    -+Var = 0 -> set var to 1

    -+Var = 1 -> set var to 0

    Am I mistaken or this behavior has changed along the way?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)