Make multiple enemies with Pin behavior?

Get help using Construct 2

Post » Mon Sep 28, 2015 10:42 pm

I want to make enemies that have some complex animations (running, idle, attacking in different ways, etc.), so I want to use the Pin to collision box approach for all of them, but when I applied the Pin behavior as one normally would for an animated sprite, the enemy sprites don't stay 'pinned' to the collision boxes unless there is only one in the layout. I hope I'm being clear. How does one make this happen with multiple enemies?
B
10
S
2
Posts: 31
Reputation: 754

Post » Mon Sep 28, 2015 11:13 pm

When dealing with multiple instances of the same object, I usually use Every Tick --> Set "EnemyCollision" position to X: Enemy.X | Y: Enemy.Y

I would have to make a .capx to test this, but this should work. If it doesn't, it might require something to spawn a duplicate "EnemyCollision" at the same time as the Enemy object. I'll check it out though.
I like giving game advice more than I actually like making games ;)

Image
B
40
S
15
G
3
Posts: 129
Reputation: 4,651

Post » Mon Sep 28, 2015 11:27 pm

I see...I think. I'm going to have to experiment, but if I'm reading you correctly, you basically did the inverse of what I attempted. Instead of putting the enemy collision boxes on the layout and pinning the sprite to them, you basically put the enemy sprite on the layout and set the collision box's position to the sprite, having that control all the collisions in the events.

I'd love to see what your .capx turns up.
B
10
S
2
Posts: 31
Reputation: 754

Post » Tue Sep 29, 2015 12:18 am

I had a bit of a breakthrough: I added an event that said "Every Tick, For Each enemySprite --> set enemySprite position to enemyBox" and that seems to work for multiple instances.

Now I need to figure out how to get them to not completely match each other's movements...got them walking but when one turns around, they all turn around, resulting in some of them appearing to be moonwalking...

Also, defeating one enemy destroys every sprite instance...this is frustrating.
B
10
S
2
Posts: 31
Reputation: 754

Post » Tue Sep 29, 2015 12:58 am

Hmmm, interesting. Could you provide a capx? Then I can see what I can do :)
I like giving game advice more than I actually like making games ;)

Image
B
40
S
15
G
3
Posts: 129
Reputation: 4,651

Post » Tue Sep 29, 2015 2:24 am

I'm sorry, I can't...part of a much larger project that I've put a ton of work into. But I think I may have found the help I needed from a friend. He helped me figure out that I need to use the enemy box to spawn the enemy sprite (kind of like what you suggested), and code it so it uses an instance variable within the enemy collision box object to pick sprites by their UID. I'm still working on applying the advice he gave me and I'm going to see if it works out.

But I'll leave this thread up in case you or anyone else has anything they might want to add...a simpler way, etc.
B
10
S
2
Posts: 31
Reputation: 754

Post » Tue Sep 29, 2015 3:03 am

kk sounds good!
I like giving game advice more than I actually like making games ;)

Image
B
40
S
15
G
3
Posts: 129
Reputation: 4,651


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Prominent, tarek2 and 13 guests