Display Group Issue/Question

So I’m having some issues with how the display groups work (or perhaps how I’m trying to make them work) and was wondering if anyone could give any insight.

So, for this I’m working on a kind of teeter-totter mechanic.  So there’s one board that two objects rest on at opposite ends.  Once the two ends have an object on it, it slowly rocks back and forth.

The best way to do this, I thought, was to have the teeter-totter object itself be its own display group.  That way, the other two objects would just be inserted into it and rotate along with it as it rocks back and forth.  This alone works fine in terms of just the rotation itself.

The problem is, when I insert those objects, it throws off the positioning of the whole group when I start trying to rotate the group, or animating it in any way.  I figure the reason for this is, with the new objects added, the technical center point of the teeter totter group changes to accompany those objects, so depending on the objects sizes, it can be displaced differently.

I’m wondering if there’s a way around this issue?  So far it seems like I just have to constantly adjust and reset the position of the group once everything is inserted, based on which objects get placed where (not all objects placed onto it are the same sizes), which is kind of messy, but if there’s a better way or some other way I could be handling this better it’d be super neat to know.

my understanding is that the physical size of a displaygroup is the sum of the objects inside, so when you add an object you are likely to enlarge the displaygroup, hence the offset in size and centerpoint.

in my particle effect creator program radiance, up to 5 emitter objects can be grouped/degrouped by the user at any point. i recalculate size and center each time to make it work.

one trick that might work in your case is to add an object, perhaps a square, that is alpha 0 or not visible, and that cover the total area you need to work with. then adding and removing objects to the displaygroup should work without displacements, provided these objects stay within the invisible squares area.

Ah, adding that square works perfectly!  I just have to adjust how collision detection works since I don’t want that whole area to take part in it, but that’s nothing compared to dealing with the problem before.  Thanks so much.

great  :smiley:

Uses SSK2, but that is because I’m way too lazy for long hand coding.  Still you should be able to take it apart:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/05/balanceBeam.zip

I don’t suggest using physics bodies on groups, but that is just me.

https://www.youtube.com/watch?v=Q5wwLZndJHU

my understanding is that the physical size of a displaygroup is the sum of the objects inside, so when you add an object you are likely to enlarge the displaygroup, hence the offset in size and centerpoint.

in my particle effect creator program radiance, up to 5 emitter objects can be grouped/degrouped by the user at any point. i recalculate size and center each time to make it work.

one trick that might work in your case is to add an object, perhaps a square, that is alpha 0 or not visible, and that cover the total area you need to work with. then adding and removing objects to the displaygroup should work without displacements, provided these objects stay within the invisible squares area.

Ah, adding that square works perfectly!  I just have to adjust how collision detection works since I don’t want that whole area to take part in it, but that’s nothing compared to dealing with the problem before.  Thanks so much.

great  :smiley:

Uses SSK2, but that is because I’m way too lazy for long hand coding.  Still you should be able to take it apart:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/05/balanceBeam.zip

I don’t suggest using physics bodies on groups, but that is just me.

https://www.youtube.com/watch?v=Q5wwLZndJHU