How do I check sprite that touched the ball?

0 favourites
  • 2 posts
From the Asset Store
Bouncing ball
$9.99 USD
Template for a bouncing ball game, fully documented in comments and video
  • Hi! very new here.

    I have a bunch of football players running in the field, and eventually one of them is going to touch the ball (projectile) and deflect it to the goal, scoring a point.

    How can I know which sprite (player) last touched the ball so that I can award him the goal?

    Many thx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • METHOD 1 - Just have two different goal objects and each goal will award the team when it goes in. (So RedGoal awards blue, BlueGoal awards red)

    METHOD 2 - add a new Global Variable (I'll call it LastTouched)

    On RedPlayer Collided with Ball -> Set LastTouched to 0

    On BluePlayer Collided with Ball -> Set LastTouched to 1

    Then when a goal is triggered, check if LastTouched = 0. If so, award red team. Otherwise, blue team.

    Note METHOD 2 means that scoring in your own goal would award the wrong team.

    Note that this does assume you already have the ball-deflection thing working, this is just for awarding the correct team for scoring.

    (btw I am assuming you mean football as soccer and not american football)

    Let me know if any other assistance is needed.

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