Duplicate instance object sprite -enemy

How do I duplicate an instance(like just click on it and duplicate…not duplicate from object panel) and get that duplicate enemy object sprite to not copy the movements and attacks of the enemy that it was duplicated from.

What is the expected result - want to have multiples of the same enemy “trunk” but be independent from one another

What is the actual result - the duplicate fires when the orginal fires and also copies movement…so if the orginal is moving so is the duplicate.

Hi,

If you duplicate the object than this is exactly what is expected (you will duplicate the variables and attached behaviors). I guess most movements and attacks are set by your events though.

This is something you can do with variables and events. If you tell us a bit more in detail what you want your enemies to do, maybe someone can give a suggestion.

Thanks :slight_smile: Currently i have a trunk enemy sprite that walks back and forth on the ground and to prevent it from falling off the edge, i added some invisible objects and if they collide, they flip and walk the other way. Also, when in the player is near the Trunk enemy, the enemy shoots bullets.

What’s happening now is if i put in a copy of that enemy, it just copies the orginal. So when the oringal moves, the copy moves, and if it shoots the copy shoots…so my copy is just shooting when not near the player and also falls off the edge because the original is walking(copies movement and can’t detect collision)

Thanks for any help. I figured it’d be as simple as duplicating it and setting a “for each” instance of trunk for all it’s events…but that didnt work either. I’m a complete newb so i’m a bit confused. lol

The problem is in your events. Maybe you can post them here. Alternatively you could also have a look at one of the example projects. This one here for instance has simple left-right enemy movement with colliders Old platformer - a game example from the GDevelop game making app | GDevelop.
You can duplicate the enemy in the editor with right-click → duplicate or just drag it from the object panel into the scene and no matter how you do it, each enemy will act independently from the other instance - change direction when it collides with the direction collider and not when the original instance is changing direction.

thank you!!! it worked. the movement is completely independent, but now i just need to sort out the shooting because only one(the orginal) is detecting the player and when it shoots, the copies shoot. Any idea how to sort that out? :slight_smile:

What are the conditions for your shooting-action? If you, for instance, take ‘Distance between two objects’ only the enemies that meet the given condition (e.g. distance is below 250) will shoot. And also here it doesn’t matter, if you duplicated them in the scene or if you dragged them from the object panel.

Let’s say you are using the ‘fire bullet’-extension, your event could look like this

Im going to try that. I followed the YouTube tutorial from gdevelop for patrolling enemies for the walking and shooting events but they just mimicked each other if i duplicated them. But now that i used the events you suggested, they walk independently of each other. So, im hoping that if i change the shooting events to what you suggested it will work.