How to increment an instance variable only to a spacific object

0 favourites
  • 4 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi guys... I need your help.

    I generate 2 teams where each team has 4 player with instance variable named "kill".

    I'm not able to increment this instance variable only when the player shoot and the bullet hit another player.

    The bullet has the instance variable with shooter and the correct team.

    pls, help me... I'm going crazy!

    really thank you for your help

  • You will need to pick the instance so 'bullet on collision with player' condition, then action is increment player.variable.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I tried it but maybe I wrong something...

    It increment only the death variable and not the kill of the shooter.

    What I wrong?

    Really thanks for help man!

  • This is a little complicated to explain, but if your event is bullet on collision with player > player destroy, then you need sub events to compare the bullet variable back to the shooter. Sub event would be something like pick player(shooter) where name = bullet.name (the variable that you mentioned to track the shooter).

    But there is a further problem, because you already narrowed picked instances to the player who was shot so 1 player, you need to open up the other players again to be picked, so first you need a sub event like system pick all players, then a further sub event with the above logic about using the bullet variable

    OR instead of using these sub events you can call a function that inside has the logic for picking the shooter and incrementing their variable and also does not have 'copy picked' enabled.

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