Shooting a ball

Hello everyone, I am new to playcanvas and trying to shoot a ball to a target.
I have a score and lives label in the UI.
I needed help with decreasing the lives remaining in case the target misses.

Thank you.

Hi @sanjay and welcome,

To learn how to apply forces to bodies in PlayCanvas study the following tutorial. You will see how to apply a force to the ball each time you interact with the game:

Now to increase/decrease the score and lives label in the UI, if they are text elements it’s as simple as this in a script attached to each entity:

// each time there is a hit
this.entity.element.text = this.score.toString();
1 Like

@Leonidas Thank you for the reply.
increasing the score I have done it. What I can’t come up with is the logic to find a way to decrease lives if the target is misses.
I have a sphere entity with collision and I have used triggerenter to find if there is a hit. But what I want is if the ball misses the target or it hits the stand of the target or it hits the ground, I need the lives remaining to be decreased.
Thank you