Pivot/weld attach to spawned object



  • My current project includes enemies constantly entering and leaving dark areas. I’m trying to incorporate an upgrade that attaches “markers” onto enemies that can be seen even while they move within the dark areas. Making this work was fairly simple.

    My main issue is that I am not able to find a reliable way to attach the markers to the enemies once the marker is spawned.

    The setup sounds simple:
    -Spawn “marker” on “enemy”
    -pivot attach “spawned object” to “enemy”

    Somehow, it just doesn’t work. I’ve tried other things like:

    Sending the enemy object’s ObjectID to the spawned marker via attributes, then having the marker retrieve the ObjectID from its attributes and running the Pivot Attach logic on their end.

    And simply:

    Marker collides with enemy, marker attaches.

    The last one yields the most success, but only sometimes and is pretty unreliable. Not sure if there’s a much simpler way of handling this that I’m just not seeing.

    Also should mention that enemies are not pre-existing but are instead, themselves, spawned into the world randomly while my level terrain generates.



  • Attaching two objects together requires both of them to be physical. It will not work on Wall or scenery objects.



  • Make sure the marker have absolutely zero mass and resistance, because that can interfere. 👍



  • @RobinsonX Thank you, but I kept both of those points in mind lol.

    I have no problem attaching two objects that I manually place in the scene, but I don’t have much luck attaching two spawned objects. Zero mass/resistance on the marker, and it’s a passable physics object.



  • @bosswave ive had problems with any type of attachments with my game actually. What i would do is the same thing i had success with mine. When u spawn the marker to the object do not setup any type of attach behavior to it. Instead put a timer for every 0 seconds or whatever seconds you choose and have it move to object. This will replicate the weld attach features with way more control.



  • I use that method too, but I find that laggy. 🤷‍♂️



  • @SplitMindGaming Thank you! I wanted to do this but I’m afraid it would hurt my game’s performance to have 5-9 timers set to 0 seconds constantly going. I appreciate the input!



  • @bosswave Can we have a link to your project to have a go?

    Not sure if this helps but I did get the basic idea to work in test project: https://bit.ly/2EtLm2n



  • @Aidan_Fire Thanks for sharing! My game logic is, unfortunately, not all in one place. There are a lot of moving parts to my game and so I simply don’t know how I would be able to accomplish that lol. My “spawn marker/attach marker” logic is performed by the spawned enemy objects, but I think I thought of a way to accomplish this thanks to your example.

    And I would definitely share but my project is pretty large and... well I guess the best way to describe the state of my behaviors would be “organized chaos” lol. Thanks again!


Log in to reply