A pinball game begins with the plunger launching the ball - it shoots up and curves over the top before gravity pulls it down into the playfield.
What is a simple way to add a curved wall to my pinball playfield using Cannon? Initially, I thought a half cylinder would be the answer but, unlike Three js, Cannon’s cylinder constructor doesn’t have options for thetaStart and thetaLength.
I imagine this could be done with a trimesh, but it seems like there would be a simpler solution?
The large glass ball is a trimesh and acts as a container. It is created from an obj geometry.
There are also two rails which are trimeshes. One is spinning inside the sphere collecting balls as it turns over. The other is outside catching them as they come out.
The balls role along them as if they are real rails.
The result is a random series of numbers every time you refresh the browser and wait.
Thank you! I’ll be checking out these resources over the weekend.
I recently purchased the Kindle version of your book, so your response is well-timed and appreciated.
And glad to hear that you have given thought to a browser-based pinball game. I’m thinking it could be an entertaining bit of immersive nostalgia when paired with XR and force feedback.
This is a fantastic resource. Thank you for sharing.
The article’s gameplay video - where the camera follows the ball around the playfield - illustrates the potential upside of using an XR device; real-world pinball differs from a video game in that the player is continuously moving their gaze over a physical playfield (like a spectator watching a tennis game) along with periodic glances at the scoreboard.
I like the idea of using XR in a limited way (standing in one spot while moving your head) to bring an old-school, analogue experience to life.
I’ve started building something now.
It’s not a pinball game, but it does have a ball in it.
And its VR. You follow the ball and control it.
The ground is made up of many CANNON trimeshes.
I’m testing it on Oculus Quest 2 using the inbuilt chrome browser.
Unfortunately, attempting to view the link with my 2019 Oculus is resulting in a WEB XR NOT AVAILABLE message (using the default mozilla browser). The desktop version looks great, so I’m a bit disappointed.
I’ve been meaning to update my headset - any recommendations for contemporary Web XR-friendly devices?
I made a trimesh-enabled function, ‘CannonCurve’, with props: {
radius,
height,
radialSegments,
thetaStart,
thetaLength
}
It returns a curved wall (could also be a ramp, depending on its orientation relative to gravity).
Since Cannon Planes are infinite (and since the Box substitute felt a little hacky), I made a trimesh function, ‘CannonRect’, to create a single 2d rectangle. In addition to the playfield ‘floor’ (as seen in the screen cap), I plan to use CannonRect to create the straight bounding walls of the pinball playfield.
I’m using CannonDebugger to develop a playable wireframe (one of the reasons I wanted an alternative to Cannon Plane).
I’ve got an fps display (via ‘stats.js’) to keep track of performance while I’m developing.
Next Steps: I’m going to do some research into the mechanics of real-world pinball games (bumpers, flippers, etc) so that I can better emulate the feel of pinball’s kinetic, visceral vibe.
I would really appreciate ongoing advice/feedback (is there a difference?). I work best when I feel confident that I’m headed in the right direction.