General questions about custom objects

I agree, custom object should be indistinguishable from built-in objects. The visual editor was a huge step in the right direction.

You can place the children objects in the custom object where you want to. You can placed them centered or offset. It might not be the same but it might work.

You could also create your own actions, expressions and conditions. You could create your own position action or an expression that returns set locations.

You could make an action that allows you to rotate the custom object around different objects instead of points.

Itā€™s not ideal. You could also create suggestions.

1 Like

The origin is (0 ; 0). You can put children instances with negative coordinates, same for the area bounds.

1 Like

thx i understand now.
The first time i got the children offsetted, but it was my fault cos i was in snap to grid mode and i didnt noticed. :sweat_smile:

but it looks like there is always a bit of offset, i mean the object looks right when rendered but the true pos is offsetted, it makes it kinda hard to work on itā€¦visually

it is how u both said since the origin is top left ā€¦but it just looks weird,

lol i dunno waz happening itā€™s now workingā€¦

itā€™s surely my fault since iā€™m editing origins,scales eccā€¦

ok sry about allā€¦itā€™s my habit to put origins of objects at centerā€¦
i understand that better not do it for custom objects

Iā€™m not sure to understand what you mean. Custom objects can have the origin at the center.
image

This is what i was doing wrong

OMGā€¦
I need to redo all my gameā€¦ :heart_eyes:

how i love my new particles bullets

1 Like

Guys ā€¦you are surely more informed than me on this matterā€¦

to dateā€¦are custom object still being worked on?

i meanā€¦any news to let c.object interact with in scene objectā€¦? like read other object vars eccā€¦?..or for example to destoy a children when something outside its event happen?

like e.g. reading a var from a non custom object inside a custom object event.

There has been some major and minor changes to prefab or custom objects. They definitely seem to like the them and continue to tweak it. The best update was when they added the visual editor.

You can search the release notes for the changes.
https://github.com/4ian/GDevelop/releases

Interacting with objects with behaviors has always been difficult unless you use function calls (actions, conditions or expressions) from the scene eventsheet that provides the objects as a parameter. Otherwise, prefabs and behaviors can only do things like collision detecting between its own child objects.

Behaviors like platforms and pathfinder interact with different objects through the use of a 2nd behavior that adds the other objects using managers or lists. I still donā€™t understand the process. Javascript also helps and might be required.

See this post for a short discussion:
https://forum.gdevelop.io/t/behaviors-and-behavors/61519/2?u=keith_1357

The easiest way IMO is to add an action to the custom object that is triggered on every frame from the scene. The action would include the other scene object(s) as a parameter. Note: if you do a collision test between a child object and a supplied object through a parameter the custom object needs to be at position 0,0. Children objects are one their own layer, so if the custom object isnā€™t in sync with the scene layer, collisions will be offset as well. The children can be anywhere, itā€™s the custom object that needs to be in sync and at 0,0.

1 Like

ā€¦As i thoughtā€¦thx for the explanation mate.

ā€¦yep i remember you already explaqined this in other threadā€¦

anywayā€¦ thx for the updateā€¦glad to see theyā€™ve not abandoned the idea.3

1 Like

Yeah, me too I love custom objects. I just wish the interactions were easier.

Iā€™m trying to think about how a collision condition would work inside a prefab because you need an object name to test against. Maybe if you could use an object as a setting or property. Something that could be done just once to create the link.

Maybe it needs events for some form of manager that would handle this.

Iā€™ve wondered if it was possible to test for collisions between children objects of different custom objects. Iā€™m not sure if or how that would work.

link an object.property to check a collision would probably workā€¦however i guess devs are already figuring out how to create conditions/actions lists for c.object and c.objectā€™s childrensā€¦.iā€¦guessā€¦

Itā€™s not just the collision ā€¦(that idd would be a must to have feature)ā€¦
but is the abilty of c.object to ā€œunderstandā€ what happen outside its events that i would like to haveā€¦
ā€¦basically to have a list of actions/conditions similar of what we have now for non c.o.

Itā€™s difficult because custom objects are like scenes within scenes. Theyā€™re self-contained. Itā€™s probably best to keep everything inside the same custom object but even if something isnā€™t practical, I love the challenge of making it happen even if itā€™s ridiculous or inefficient.

Say I had 2 custom objects. They both had apples and baskets. I can easily test if prefab1 apples are in collision with itā€™s basket but not prefab1 and prefab2 apples or baskets.

A cheap workaround might to be using scene variables and create an array of the position of the apples or at least the apple that is being dragged. Another variable could track the drag state.

This is all inefficient but I could then check the distance between the variable position and the apples or baskets in the other prefab. You could even use a hidden test object and move it to the position in the variables and test for a collision between it. You could then trigger a delete in the one prefab and add the object to the other prefab.

Again, this is impractical but Iā€™m just trying to brainstorm.

yep it would works for simple collision boxesā€¦or something simple in generalā€¦
you basically doing something like the ā€œpoint insideā€ condition.
ā€¦not performances friendly but it should works as an hybrid collision check.

1 Like