Hello!
I have just started using javascript (hardcore learning )
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
this.eventkey_W;
or
if.(this.eventkey_W);
Hello!
I have just started using javascript (hardcore learning )
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
this.eventkey_W;
or
if.(this.eventkey_W);
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;
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);
this.entity.rigidbody.applyForce(force);
}
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:
https://developer.playcanvas.com/en/tutorials/first-person-movement/
Oh, I will remember that and try do it myself
this I will try and remember
For other scripts
Wait @Leonidas,
How will you define the entity
?
Would you say this.ball.forward
because ball
is the name of the entity
?
No need to define it this.entity
is always the entity the script is attached to.
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>")