Multiplayer: Detect Enemy Team/ Friendly Fire

  • I'm making a multiplayer team tank game. Each game has a base and a turrets and the objective is to destroy the opposing team.

    The number of teams is dynamic e.g. between 4-6 teams.

    I'm now trying to build a turret that can detect a tank from an enemy team but leave a friendly team alone.

    I've put the sprite ThisPlayer and Peer into a Players family, and added a family instance variable TeamID.

    The turret also has a TeamID.

    So I did this for events.

    But the turret targets everyone in the Players family even though ThisPlayer and the turret's TeamID are the same.

    What am I doing wrong?

  • Hard to say just from the screenshot. If you debug it and actually confirm that both the turret and player have the same ID it should work. If you make a small example project I could take a look at it.

  • Thank you WackyToaster.

    Here's a sample c3p file.

    drive.google.com/open

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hmm so I checked it out. It seems that the action does not take picking into account and that actually appears to be by design. The action is also meant to only be called once (or whenever needed) and not continiously.

    However, you can do this. I don´t know if this is the most optimal way of doing it, but it appears to work.

  • Thanks Wackytoaster!

    It works! Seems like the logic will handle new Peers joining midway as well...

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