Container + turret problem

New releases and general discussions.

Post » Fri Feb 13, 2009 9:40 pm

Hello all,

I'm a bit new to Construct, but I've chewed through the demos and tutorials. So far, I've gotten pretty far on an idea but I'm currently stuck, even after searching through the forums.

I'm trying to make a controllable row of soldiers. Nothing very fancy, just add a soldier sprite to a couple turrets, and add turrets to a rectangular container, right? Well, just one additional feature - I want to make the soldiers/turrets individually destructable. They get shot, go boom as individuals instead of ALL of them at once, basically. That's my goal.

Is this possible with containers? if so, how?
if not, what would be a good alternative?
B
2
G
3
Posts: 18
Reputation: 886

Post » Fri Feb 13, 2009 9:47 pm

I don't think thats possible with containers. I dont think containers were designed to be used for things like this.

You can do this using variables and other things... No time right now so I'm sure someone else will reply and help you out.
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Fri Feb 13, 2009 9:59 pm

You want to use Pairer Object for this. You pair the soldier and turret, etc., when one gets shot, the other doesn't get destroyed.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sat Feb 14, 2009 12:08 am

Welp, I realized I didn't quite explain what I was wanting to do correctly. My goal is to make a controllable row of destructable units, that stay in formation. You control the entire row, not the individual units. Kinda like a unit of fighters in Home World. Each fighter in the row can be destroyed individually, but the player controls the entire row.

The original idea I had was to use a container and turrets. You take a rectangle, attach 4 turrets to it in a row, and attach a soldier sprite to each turret. The problem is that if you pile everything into a container, and you destroy 1 turret, all turrets in the container get destroyed.

Honestly, I think the RTS template included with Construct was a better way to do this. But I don't know of a way to make the units move in a row instead of an unorganized mob. I thought the container/turret idea was a simpler way to try to do it, but it might not work.

Anyone have an idea on either option?
B
2
G
3
Posts: 18
Reputation: 886

Post » Sat Feb 14, 2009 1:56 am

I would simply make each sprite have the turret behavior, as well as the rts movement behavior.
You can then add each to a family, then when you have them move have them move with a for each saying
for each family move to x,y + private variable
>add x to private variable

Any way Im not a 100% sure, but thats a good place to start experimenting.
Image Image
B
161
S
48
G
90
Posts: 7,350
Reputation: 66,755

Post » Sat Feb 14, 2009 3:19 am

If you trying to make groups of the same objects, add a private variable called 'group id' or something, and when you create say 4 soldiers, give them a number (such as a global variable that you can incriment).

Then if you need to select a group, you can just compare the private variable. I'd also recommend adding a family because then you can do stuff like this:

On left click soldier
FamilySoldier - Select all with 'groupid' equal to soldier('group id')

And then FamilySoldier will be all the soldiers in the group, and soldier will be the one you actually clicked on :)
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Sat Feb 14, 2009 6:34 am

Wow, better responses than I hoped for! The family and group selection ideas look like a great foundation to getting the rows going. Gonna try these tommorrow, er, later today now that it's so late, and see what I can come up with for movement.

Must.Get.Sleep.
B
2
G
3
Posts: 18
Reputation: 886


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 0 guests