How do I move an object to a custom point on another object

I’m struggling to get an object to be positioned to another objects custom point. The intention is to be able to rotate the object in the game according to mouse position, but I cant get the gun object to attach to the player object at all. I read about PointX and PointY on some things I’ve searched, but it isn’t working for me.

Sorry if this is a stupid question - is there a point named Gun (remember it’s case sensitive) on the PlayerDog object? If there is, are you setting the position in an event that gets actioned every frame? You can’t just position it when the PlayerGun is created, it needs to be repositioned when the PlayerDog object moves.

It needs to be updated with the player. This is code I used in my game when the character donned a new hat, it kept the hat on while the character ran around, and rotated/etc… as needed so it looked like the character was actually wearing it. Maybe this helps you solve your issue as well.

1 Like

Just a heads up - instead of doing this in events yourself, you can use the Sticker extension. You stick the hat onto the Monkey once, and the extension keeps it in place and rotated when the Monkey moves.

Oh very cool! I did not know there was an extension like that. That game snippet is one I finished a year ago, but if I need to do that again in another one, I will def. check it out!

I can not get the stickers to work, not sure what I’m doing wrong there. I’m using the method in the gdevelop example to pin one object to another instead. The single parent one.

If the op can’t get the stickers to work either there is a video with point carrying that might be helpful. I don’t think the gdevelop pin it example would be helpful because it assumes PlayerDog is born into the scene carrying a gun already - which could have just been drawn there to begin with instead. The video shows picking up something in the game.

How to carry and place items | GDevelop 5 Tutorial - YouTube

You need to install the extension, and add the sticker behaviour to the object you wish to stick. In actions, select the object, then select stick option and choose the other object to stick it on.

I did all that but it didn’t work. Maybe because I didn’t change the origin points since I notice i do have to change them to get the pin it example to work. Or maybe because I was using a tween to move the other object. I’ll have to look at it later and see if I can figure it out.

Oh, one other thing I just thought about, and I have wasted much time on this foolish mistake, but also make sure its ZOrder is above the item it is pinned to. I worked for a long time wondering why it wasn’t working when it was there, just behind the object! ( I had created the object to be “pinned” but forgot to set ZOrder . Talk about tearing hair out for nothing! :slight_smile: So just a heads up to anyone else in the future

If you’re still having trouble, screen shot the events and how the gun & player look on screen when you play the game.