Hi guys,
I’m new to Cocos and I’m trying to apply an impulse to my node when I’m pressing KeyCode.SPACE.
In particular I’ve a Node with RigidBody2D component and a script.
Inside the script I’m trying to do this, but doesn’t works:
onKeyDown(keyboardEvent: EventKeyboard): void {
switch (keyboardEvent.keyCode) {
case KeyCode.SPACE:
this.rigidBody.applyLinearImpulseToCenter(this.force, false);
break;
}
}
The force is a Vec2:
force = new Vec2(0, -25);
Any suggestions?
Thank you!!