I have a shoot point called shooterPos on the scene. First time it is fine, bubble is shot from it. Butt on the second time, the bubble is shot from the targetPos to the shooterPos
Here is my code of the method:
i want to shoot all the bubbles from the shooterPos
createShotBubble(angle: number, direction: Vec2) {
const bubbleNode = instantiate(this.bubblePrefab);
const bubble = bubbleNode.getComponent(Bubble);
bubbleNode.setPosition(new Vec3(this.shooterPos.x, this.shooterPos.y, 0)); // Set initial position to shooterPos
this.node.addChild(bubbleNode); // Add the bubbleNode to the piecesLayer instead of the PlayerController node
const targetPos = this.shooterPos.add(direction.normalize().multiplyScalar(this.shotSpeed));
console.log('target: ', targetPos);
tween(bubbleNode)
.to(this.shotDuration, { position: new Vec3(targetPos.x, targetPos.y, 0) }, { easing: 'sineOut' })
.call(() => {
bubble.destroyBubble();
})
.start();
}
New contributor
Hiếu Trần is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.