Car Spawner

0 favourites
  • 4 posts
From the Asset Store
2 Cars
$5 USD
An interesting and very challenging car game!.
  • Hi Construct 2 lovers!

    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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • 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.

    [Condition On created car_to_change_2 colorChoosen=0]

    action - car_to_choose_2 set frame random(0,3)

    action - colorChoosen=1

  • Thanks for useful tips!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)