[SOLVED] How to make a bowling ball roll?

I have just started using javascript (hardcore learning :laughing:)
and I want to create a game by myself for bowling but I was wondering how will I make the bowl roll?
Like do I have to use


I am very sorry if none of those are correct, I have learn’t coding but I cannot seem to find the right way to do it here in PlayCanvas

Wait I think it went like this.eventkeyup_W;

Hi @Gabriel_Dobrzynski,

You need to apply a forward force to your ball to get it to roll on keypress:

if (this.app.keyboard.isPressed(pc.KEY_W)) {
   var power = 100;
   var force = new pc.Vec3().copy(this.entity.forward).scale(power);

Change the power value depending on your bowling ball mouse to not be too big or too small. For a more elaborate controller check the following example:



Oh, I will remember that and try do it myself

this I will try and remember :smile:
For other scripts

1 Like

Wait @Leonidas,
How will you define the entity?
Would you say this.ball.forward because ball is the name of the entity?

1 Like

No need to define it this.entity is always the entity the script is attached to.

1 Like

this.entity just refers to the entity which is attached to the script essentially, you need not have to get the Ball entity unless the script is not attached to the ball entity. In the case you need to refer to an entity by its name use
this.app.root.findByName("<Entity Name here>")


Thanks @agent178 and @Leonidas!