Car Spawner

Get help using Construct 2

Post » Sun Dec 27, 2015 2:15 pm

Hi Construct 2 lovers! :D

I'm creating a simple car game and I have a little problem with car spawners.

So it's looks like this:



I want that every car has a random color (that's a 1 object who has 4 frames [0-3]).
I've already tried add expression car_to_choose_2 | Set animation frame to random (0,3).
The only problem is that the C2 changes color every car every few seconds when it's creating a new object.. :?

Maybe someone has an idea how can I write this shorter without using four car spawners, but using just one. Unfortunately, the car must go in 4 different global sites and it is the biggest obstacle.

Thank you in advance for help! ;)
Posts: 22
Reputation: 255

Post » Mon Dec 28, 2015 12:11 pm

I solved this problem for my own. If someone was curious or just needed a solution:
Just use 2 expressions: car_to_choose_2 | Set animation frame to random (0,3) & car_to_choose_2 - On created | car_to_choose_2 - Stop animation
Posts: 22
Reputation: 255

Post » Mon Dec 28, 2015 4:52 pm

Glad you solved your issue. Let me point out why it was happening which might help you with other Construct2 instance handling.
Construct2 relies on instances (objects of the same type) being "picked" by conditions so it knows exactly which object you want manipulated.
If you don't let it know which object to pick it will pick all that apply and you will get "fish schooling" behavior.
I highly recommend searching for object picking in the Construct2 manual, very handy info.

Each time you told your car to change colors it changed them all since they are all car_to_choose_2.
Your fix method worked because it basically turned off all but new instances.
Another method would be make an instance variable in car_to_choose_2 called something like colorChoosen=0 and then when it is colored change it to 1 (colorChoosen=1) and condition to colorChoosen=0 (or not (X) colorChoosen=1) in your color change event.

On created
car_to_change_2 colorChoosen=0]
action - car_to_choose_2 set frame random(0,3)
action - colorChoosen=1
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
Posts: 637
Reputation: 9,370

Post » Mon Dec 28, 2015 9:30 pm

@chrisinfinger Thanks for useful tips!
Posts: 22
Reputation: 255

Return to How do I....?

Who is online

Users browsing this forum: lukewasthefish, marc254, tarek2 and 11 guests