How do I…
Make an NPC that spawn with multiple objects (example: with eyes)
What is the expected result
the two NPC should spawn with each own eyes
What is the actual result
Only the last NPC to spawn has its own eyes
Make an NPC that spawn with multiple objects (example: with eyes)
the two NPC should spawn with each own eyes
Only the last NPC to spawn has its own eyes
GD doesn’t know which objects go together. You can link the objects together and use take into account all objects linked to object to pick the linked objects.
Here’s an example that creates and links a head and arms. The head has the drag behavior and a point for each arm. The arms origins are moved moved to the base of the arm.
Result of dragging 1 head
but what about the clamped Pupil? Look closely on my screenshot
aw shoot, it got worse instead
Can you post a screenshot of your events that aren’t working?
The point system isn’t always needed for positioning. It works well for fixed objects. If you link all of the parts to a common object like body then you can pick the objects linked to it. Then use the body or any other picked object as the reference. Make sure you pick all of the matching parts first and then place them. In your example the object name red might be considered the main or parent object. You could link the other parts to it.
You would first need to pick the body or red and then pick the other parts through their link like in my previous example. You can use for each body or whatever object that you choose to be the main object or parent. It’s a lot like a family tree. You have a parent linked to various children.
While the order that they are linked doesn’t matter. Let’s say you have 2 objects. A and B. You could link A to B or link B to A.
You can’t link A instances to A instances or B to B but you can link multiple A objects to multiple B objects. Just remember only 1 link can be created per action. So, you need to make sure the appropriate instances are picked before the link. The easiest time to create the link is right after the objects are created. That way the appropriate instances are the only objects currently picked.
When you pick the object linked to another object, you’re picking the objects that are linked to a specific object. It can return multiple instances if there are multiple instances of the same object linked to the main object.
Create the parts. You could use the object named red as the parent. Link each object to red.
Create red
Create left eye
Create right eye
Etc…
After the parts are created, in the same event or a subevent of it.
Link left eye to red
Link right eye to red
Then to position it.
For each red object
Take into account all left eye objects linked to red
Take into account all right eye objects linked to red
Etc
That would pick all of the parts. You can then position them or do anything else like deleting them. Each time to you need to pick the linked objects so Gdevelop knows which objects to use.
Position red
Position the left eye using red as the reference
Position left pupil using the left pupil as reference
Etc.
Linking was a hard concept for me. It got much easier. It’s a lot easier than maintaining ID variables.