Shooting with cannon

Hey community , i start work with cannon with threejs , i want to make thing like shooting sphere with mouse , so i think , i have to set gravity to zero with every click to stay the spheres in there place , but how i can make the collision with other spheres ? , this the base example i made , any tips to do that ?

Is that a good way to make sphere in physic world (not visible ) and shoot on click , to make shooting effect , i have an ideas but not sure of its

schteppes examples are a good place to start
schteppe/cannon.js @ GitHub

In particular
cannon.js + three.js physics shooter (schteppe.github.io)

I also have an example,
ConvexObjectBreaker - Three.js Tutorials (sbcode.net)

You can set the velocity of a cannon body.
eg, If I have set up a bullet body, I can shoot it out of the camera using.

const v = new THREE.Vector3(0, 0, -1);
v.applyQuaternion(camera.quaternion);
v.multiplyScalar(50);
bulletBody.velocity.set(v.x, v.y, v.z);

Thank you for replay , i found it hard, actually i want to achieve like this effect Developer Website - Contacts Page by Artem Buryak on Dribbble there specific thing i must search on it?

in this
Cannonjs with DragControls - CodeSandbox
you can drag a ball around using the drag controls and it knocks the other balls out of the way.

1 Like

here is another example that uses point to point constraints.
You can drag the balls but there are constrained to a point.

I think the example not working , or my bad?

it worked for me, even on mobile

Try this url instead
Point to Point Constraints - Three.js Tutorials (sbcode.net)

1 Like

That’s Work , oh all i need now to make this effect on mouse hover (Is this possible?), thank you so much !

Hello Mr, can i set the spheres as asymmetric pile??