...control multiple (pinned) entities of same type

Get help using Construct 2

Post » Sun Nov 06, 2011 9:45 am

Hello Guys,

I have problems controlling composite entities. What I need is an object consisting of multiple sprites. The reason for that is that each sprite should start its animation in parallel. Example: Enemy consists of leg sprite and torso sprite. When the player gets near it should start walking in the direction of the player turning on movement animations of leg and torso sprites.

Here is an example project that doesn't do what it should. For each torso (redSprite) I create a leg (greenSprite) and pin the torso to the leg.

http://dl.dropbox.com/u/40417570/Tests/MultiSpriteProblem.capx

Movement animation is symboled with the flashing behaviour.

Problems:
- multiple legs are spawned for each single torso (!?)
- torso doesn't move with legs
- torso doesn't start its animation

The main problem arises with the need of multiple enemies of the same type. I got everyting working with only a player and one enemy.
The examples I've seen that use multiple enemies only do basic stuff (moving a single sprite, no animation).

I would appreciate any help!

Michael
B
34
S
8
G
6
Posts: 34
Reputation: 4,942

Post » Sun Nov 06, 2011 6:17 pm

See if this is what you want : http://dl.dropbox.com/u/2472278/Files/MultiSpritePossibleSolution.capx

Basically you had some problems with loop arrangement , use of trigger once etc, and mainly you had to save the torso UID on their legs to refer to them later. I also changed the movement with Bullet, to a move at angle calculating the angle between the player and the enemies. Kiyoshi2011-11-06 18:20:54
B
58
S
13
G
10
Posts: 632
Reputation: 12,515

Post » Mon Nov 07, 2011 9:07 am

Thanks alot Kiyoshi, it works pretty well, even though there are still some issues but the big question about how you can reference items from other items is answered (using the UIDs). That will help me alot.

(Btw. the link refers to something else, but using the address I could download the project.)
B
34
S
8
G
6
Posts: 34
Reputation: 4,942

Post » Tue Nov 08, 2011 12:05 am

Glad that i was of help. Well the link problem must be a forum bug since i used the Insert Hiperlink button.
B
58
S
13
G
10
Posts: 632
Reputation: 12,515

Post » Fri Nov 11, 2011 12:47 pm

Sorry to come up with this again. But I'm facing a problem that seems to be a bug to me. I updated the solution given before to stop animation (blinking effect in sample) if the player leaves the field of sight. It works well with the given 100 pxl but when changing the range say to 200 things become ugly. Now often the animation is not triggered but the enemy moves towards the player (which in fact should never happen). I added a global variable "Range" to easily updatate the value. How can the distance between the player and the enemy have such a strong effect?

Thanks for any help.

Ps: What is the best approach for something like an else case. So far I just copy the previous condition and invert the statement but this seems very inefficent to me (code duplication).
B
34
S
8
G
6
Posts: 34
Reputation: 4,942

Post » Fri Nov 11, 2011 12:48 pm

B
34
S
8
G
6
Posts: 34
Reputation: 4,942

Post » Fri Nov 11, 2011 1:22 pm

After playing around with a single sprite version (having the same problems) I found out that the System->TriggerOnceWhileTrue condition doesn't do what it should (trigger animation only once .. for each sprite)
I changed it to set a bool on each sprite (flashing) which basically should be the same, however here it works.

http://dl.dropbox.com/u/40417570/Tests/SingleSpriteWeirdBehavior.capx

I did the same for the multisprite project with some more astonishing results. All sprites except one (the first created?) work ?!

http://dl.dropbox.com/u/40417570/Tests/MultiSpriteWeirdBehavior2.capx

I really like this toolkit, but it gets rather fast frustrating to work with.
B
34
S
8
G
6
Posts: 34
Reputation: 4,942

Post » Fri Nov 11, 2011 1:40 pm

Fixed

It was just a matter of reorganizing the events. (I fixed the very last version you proposed "MultiSpriteWeirdBehavior2")

And there is a big range, making all of the ennemies in range from the beginning.

You don't need to have billions of "for each" loops.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Fri Nov 11, 2011 1:50 pm

Wow, that was quick. Thanks a million. So it was the dummy object that one needs to create outside for using dynamic objects. Good for pointing out the loop overhead, I feel abit stupid now though :-(
I still don't know the use case of system->trigger once but I'll try to avoid it now...

Michael
B
34
S
8
G
6
Posts: 34
Reputation: 4,942


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests