Issue on Spawn Object's Imagepoint

Get help using Construct 2

Post » Mon Feb 02, 2015 9:30 am

I have 10 imagepoints on the enemy (not including origin point) and I want to spawn a spark on a random imagepoint number from 1-10

So I use an event like this

Enemy on collision with player
For Each Enemy
-> Enemy spawns spark at layer 0 at imagepoint choose(1,2,3,4,5,6,7,8,9,10)

but it spawns 10 sparks at the same time

I tried this
-> Enemy spawns spark at layer 0 at imagepoint floor(random(10))+1

but it spawns 10 sparks the same.

Is it not possible to use expressions (system expressions, that is) for imagepoint?
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Mon Feb 02, 2015 9:37 am

Have you tried adding the "trigger once while true" condition after yours?
For example:
(enemy.X > 10 && Trigger once while true) ->Enemy spawns spark at layer 0 at imagepoint choose(1,2,3,4,5,6,7,8,9,10)
B
8
S
2
Posts: 13
Reputation: 544

Post » Mon Feb 02, 2015 9:41 am

I can't use "trigger once while true" because on collision is a trigger condition.

I did try "trigger once while true" as a sub-event condition. I don't know why it still spawns 10 spark objects.

I also tried adding (3rd level) sub-events under "trigger once while true" event like these:

choose(1,2,3,4,5,6,7,8,9,10) = 1
--> spawn at imagepoint 1

choose(1,2,3,4,5,6,7,8,9,10) = 2
--> spawn at imagepoint 2

and so on

still spawning 10 sparks
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Mon Feb 02, 2015 9:50 am

You yourself mention having a "For each enemy" - this shouldn't be needed as on collision they are already picked. Also I'd use random(1,10) for the imagepoint choice.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Mon Feb 02, 2015 11:01 am

you could do it like so
You do not have the required permissions to view the files attached to this post.
B
257
S
43
G
15
Posts: 1,992
Reputation: 41,535


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests