#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# I can't constrain two objects!

Posts: 23Member
edited October 2017

Hi,I know this is probably a stupid question but I am new to GS so can you tell me how to make 4 actors staying together and spawning randomly as 1 actor on the scene.Here is an example picturehttps://c1.staticflickr.com/5/4509/24154255608_d85c0d637b_b.jpg

• Posts: 400Member, BASIC

Hello.

In short. You need to choose a main actor. This actor will need to constrain its X and Y values to game.attributes (real).

For each actor that is not the main and needs to be connected, you need to work out the difference in X and Y values from the main actor. So each actor will constrain their own X and Y positions to the value of the Game Attributes, Plus or Minus, the distance between them.

Not sure if that is explained very well, so attached is a demo. Touch and move the white actor. The pink actor will constrain to it.

Hope it helps.

Two.E

• Posts: 23Member
edited October 2017

@Two.E I appreciate it, but can you tell me how to spawn them randomly when they are constrained

• Posts: 23Member

I know it is currently implementable, but wanting to spawn a group of actors to act as one (mainly for more complex collision types) is a hassle. If I were able to have actors grouped together under a single actor (even if with position being relative to that single actor), that would save some time.Please help.

• Posts: 11,134Member, Sous Chef, PRO, Senior Sous-Chef

Ah to have Graphene...

Yeah, it's a lot of work to set that up.

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Posts: 23Member

@tatiang ok can you explain it to me or can you give me link to go and find the info
Much appreciated

• London, UK.Posts: 12,832Member

"wanting to spawn a group of actors to act as one"

What does 'act as one' mean ?

• Posts: 23Member

@Socks I mean when they spawn randomly on the scene they will stay together and spawn as they were 1 actor and not separate

• London, UK.Posts: 12,832Member
edited October 2017

@chrisstoyanovworks said:
@Socks I mean when they spawn randomly on the scene they will stay together and spawn as they were 1 actor and not separate

What is the difference between the actors being 'separate' and them being '1 actor' (I am trying to understand your question) ?

• Posts: 400Member, BASIC

Hi, I am 99% sure I provided a demo that should do the trick in your other thread. I assume this is the same problem.

The demo showed you how to constrain to a main actor when they are placed on screen. Which means you already know, before the game starts, the distance difference between the main actor, and the one that needs to spawn.

Which means, when it spawns, it will automatically constrain itself to that positioned.
You just have to know where you want it constrained and add that into the constrain behaviours.

Best,
Two.E

• Posts: 11,134Member, Sous Chef, PRO, Senior Sous-Chef
edited October 2017

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Posts: 23Member

@Two.E I was struggling to constrain when I have 4 actors, can you tell me how to do it with more than 2 actors
Thanks

• Posts: 400Member, BASIC

Hi,

Attached is another demo. Touch the white actor to move around. The first time you touch it, it will spawn 4 other actors that will be "Attached" to it.

Hope it helps.
Best,

• Posts: 23Member

@Two.E Thank you so much I appreciate the help and I will try and see if it works for me

• Posts: 23Member
edited October 2017

Thanks for the help but one last question,I managed to constrain them but now I want to spawn them randomly on the scene but not when actor is touched but with a set timer for spawning.
Thanks for the help
@Two.E

• Posts: 400Member, BASIC

I really would suggest to have a play around with the demo. Take a look what is happening. If the colour actors are spawning when the white actor is pressed, then you need to find a rule where the actor is pressed.

Now you know what happens when it is pressed. So if you want same thing to happen after a timer. You would copy those spawn behaviours, and place them inside a timer instead. (Not in a rule).

I don't think I can do too much more if you don't understand the very basics of GS.

Hope it helps.
Best,

• Posts: 23Member

@Two.E I fully understand thanks for the support.

• Posts: 23Member
edited October 2017

Hi,Can someone tell what am I doing wrong because I want to spawn 3 constrained objects on the scene with a timer but everything that I am trying to do to spawn them for example( to use when touch is pressed or when actor collides)isn't working.Please help thanks in advance.Here is a link to an image of the project. https://flic.kr/p/ZZKodV

• London, UK.Posts: 12,832Member
edited October 2017

@chrisstoyanovworks said:
Hi,Can someone tell what am I doing wrong because I want to spawn 3 constrained objects on the scene with a timer but everything that I am trying to do to spawn them for example( to use when touch is pressed or when actor collides)isn't working.Please help thanks in advance.Here is a link to an image of the project. https://flic.kr/p/ZZKodV

It will take three seconds before the actors are spawned, are you waiting three seconds to see if it works ?

Do the spawned actors - once spawned - move around the scene ?

Are you - at the time of spawning - looking at an area of the scene that shows Y=6,500 ?

• Posts: 23Member

I figured out the problem by setting another actor on the scene and using him as a spawner actor but the problem now is that when the actors spawn the layering isn't working as I set it.Please help

• Posts: 400Member, BASIC

The actors being spawned will either be placed "In Front" or "Behind" the actor that is spawning them. Or, at the "Front" or "Back" of the layer.
Hopefully that makes sense.

However, logic runs from the top of the actor, downwards. Which means if you have more than one Spawn Actor behaviour: (And we choose "In front of Actor"

The first actor spawned is going to be at the top of the layer, since the only other actor is the one that spawned it.

The second actor spawned is going to be in the middle of the layer. Because it will be spawned "In Front" of the actor that is spawning it. But, that doesn't mean it will go in front of the previous actor spawned. Therefore this second actor spawned will be behind the first actor.

This will continue throughout. Therefore, you need to structure the behaviours to suit your needs.

Not sure if that helps.

Best,

• Posts: 23Member

Thanks but that doesn't solves the problem the other actors still stay "behind'' the main actor,I mean they spawn in front of the main actor in the scene but when the main actor collides with them they are underneath him.I hope someone knows the answer to this dilemma.Thanks in advance