Jump to content

WIP: Visual Pinball in Unity (2021 Edition)


Recommended Posts

@slydog43 We've always been using the -preview tag to release. Basically, until we hit 1.0.0, we're at 0.0.1-preview with the preview number increasing by one on every merge. Nothing new here.

 

@hitman12 If you read through the GitHub issues you'll notice that most of the tickets are improvements or just things we put so we don't forget about them. We actually have a playable game, but there is sound missing and we don't have a player app yet. Those are currently the two main blockers for more a public release.

Link to comment
Share on other sites

  • Content Provider

I saw the pinmame running video.  Was wondering how far out is the scripting module for vpe.  I have my bad cats imported and im slowly correcting all the graphics and materials.  Just wondering how far out scriptingwill be

Link to comment
Share on other sites

You don't need any scripting for PinMAME to work, but unfortunately we're still lacking documentation about how to set it up.

 

We have started working on a few table projects now, and are still figuring out a lot of stuff. Once it's more clear we'll start documenting (starting with PinMAME), so be aware that it might be necessary to re-do things if you've already started your build.

Link to comment
Share on other sites

  • Content Provider
1 hour ago, hitman12 said:

Can You post some screenshots from Bad Cats imported to VPE?

Yes.  Everything is tinged green at the moment.  I literally just set unity and vpe up last night.

The import looks very nice.  Just realized it was a vr room and everything was imported.  Wondering if i should strip the room out first and then import

Link to comment
Share on other sites

You can easily hide stuff by selecting the element to hide and clicking on the top left checkbox in the inspector. This will mark it as inactive and will basically ignore it. That's also how we work, import a table, hide everything and go through every element to bring it back.

 

The green tint is due to a missing diffusion profile of translucent materials. Select the material, make sure it actually has to be translucent (otherwise, set it back to standard), and if that's the case, assign one of the diffusion profiles at Packages/Visual Pinball Engine (HDRP)/Assets/Settings/Diffusion Profiles (in the Project panel). You'll need to drag and drop it into the inspector because when browsing, the inspector doesn't look into Packages, only into your scene.

Link to comment
Share on other sites

@freezy The work that you've done here is absolutely amazing!  @Bord told me that you have working logic for a Volley EM machine.  I haven't been following along for several months but I was wondering, did you incorporate any score motor logic into the visual scripting portion of VPE? 

 

Just for reference for anyone not familiar with them, old EM's use a physical score motor that rotates a series of disks that toggle switches on and off in a six index run.  The score motor is used for resetting the table to drive the score reels back to zero as well as for any scoring event that is a multiple of a score value like 50 or 500 or 30.  Single scores like a pop bumper do not use the score motor so they can score as fast as possible.  On an EM, you'll see that the table designers always put multiple scoring events far enough away from each other so that no more than one can be active at one time.  This is because EM's have no "memory" so a second multiple score event cannot occur while another is in progress. 

 

Gottlieb score motor

gottlieb.thumb.jpg.cdc93ba0cc9f963ad32813fe873d0c81.jpg

 

Williams score motor

williams.thumb.jpg.d7448206c63ed1f090f0dd29c7907a32.jpg

 

 

One of the keys in my mind to emulate an EM well is to have a mechanism that fires six times at around 160ms for each pulse to emulate these score motors.  This can be used to emulate the click-click-click-click-click pause click-click-click-click-click of a reel resetting to zero or the ding-ding-ding-pause-pause of a 300 point score.

Link to comment
Share on other sites

@jsm174 can give you more details, but from an interface point of view, we have a node that allows you adding points to a variable, and another node that applies a number to a number-compatible display (which can be a score reel, but also a digital segment display, in theory even a DMD, but I haven't implemented number rendering on the DMD yet).

 

The display is then responsible for rendering whatever it gets. For the score reel, it's an animation of the wheels. As far as I know, the fact that the motor has no memory is handled in a separate graph. It basically checks whether the motor is running and only then sets the score to the display.

 

You should give it a try!

Link to comment
Share on other sites

@scottacus

 

It would be fantastic to accurately simulate the score motor!   I had looked at https://www.funwithpinball.com/learn/animated-schematic-diagrams and thought it would be interesting to look at the source of emsim.

 

As for Volley, some work is still needed in that area.   @Cupiii did some amazing in-depth studying of the schematics. From that we did some pseudo code:

 

AddScore(x) { 
   if (scoreMotor == 1) return;

   if (x == 500 || x == 5000) {
      scoreMotor = 1;
      wait 15ms
      for (i = 1 to 5) {
        update score + x/5
        wait 135ms 
      }
      //wait some more until 768 ms
      wait 78ms
      scoreMotor = 0
   }
   else { 
      update score
   }
}


Then we mapped it out with our Visual Scripting nodes:

volley_scoring.thumb.png.4fc71d491acc9afbe120ff054cc939cc.png

 

Quote

One of the keys in my mind to emulate an EM well is to have a mechanism that fires six times at around 160ms for each pulse to emulate these score motors.  This can be used to emulate the click-click-click-click-click pause click-click-click-click-click of a reel resetting to zero or the ding-ding-ding-pause-pause of a 300 point score.

 

So, currently, we are "trying" to do that, (bottom For Loop), but I'm sure it could use some work. 😄

 

 

Link to comment
Share on other sites

The pseudocode looks great as you have that ability to:

-block a second "multiple-score"

-delay 135ms between scores

-delay an additional 78 ms for the score motor to get back to the "index position"

 

Once you get to making a reel reset section you can use this again for driving the score reels back to 00000.  The 78ms will work nicely for the delay between the first five resets and the last 5 resets (1-2-3-4-5 pause 6-7-8-9-0).

 

In my example I used 160ms rather than 135ms because some physical chime units in pin cabs can't cycle fast enough to make good rings of the chimes at "speeds" greater than 160-150ms.  The reason is that the unit has to physically raise the slug to hit the chime bar and then have enough time for the slug to fall far enough to be ready to cycle again.  A time of 135ms might be too fast for some cabs but if the end user could change that to suit his cab I think that would be fine starting point.

Link to comment
Share on other sites

So sorry to come here with such a basic problem but, Ive looked all over for answers and tried to find a discord channel that may help but I've had no luck.

So Im following this guide here to install VP for Unity, https://docs.visualpinball.org/creators-guide/setup/installing-vpe.html

Everything seems to go okay except, I am not getting a "Visual Pinball" menu item added to the top menu in Unity, and its not being added within another menu as far as I can tell. -There are some Visual Pinball menus that have been added such as in "Game Objects" menu.

And it appears without that menu I can import a table next as described here, https://docs.visualpinball.org/creators-guide/setup/running-vpe.html 

Thanks and if there's a discord I should be using please let me know. 

PS Im on Unity 21.2.12 and I have tried restarting it.

Edited by Fizzletop
Link to comment
Share on other sites

4 hours ago, freezy said:

Hard to tell. Anything suspicious in the console?

 

We'll be providing a sample project in the future to get you started more quickly and with less headache.

Yes, like 7 red errors and 4 yellow... which on first following the documentation stops the VPE menu from being added to Unity menu bar so you cant import a project, which I thought may solve some of the errors where the packages seem to be looking for stuff like lamps... Now I also noticed in the documentation that PinMame has to be installed so I thought I'd try running through the steps backwards and starting with it. So I went to remove the Pinball.Unity.HDRP package and as soon as it was removed the console cleared up and the VPE option got added to the menu bar. 

So the packages I have installed now are Visual Pinball Engine and Visual Pinball Engine (PinMame). And no HDRP pinball package but the Unity project is still HDRP, so all the materials are pink and nothing looks correct plus no ball on test play and the flippers lag horribly, but getting closer.

So I just tried a new Unity URP project and doing the VPE documented steps again of installing PinMame package, which automatically installs Visual Pinball Engine with it. Then I loaded the VPE URP package. After which I loaded an nFozzyExample table from a VPE.10 (x) file that I have. It's working better but of course it isn't very pretty in URP and still some ball spawn problems on play.

So back to the HDRP project, here's what's poping up, with or without a table loaded in an HDRP scene.

Capture6.thumb.PNG.f666eac609f7569b0692e514bb53e663.PNG

Link to comment
Share on other sites

On 4/5/2022 at 10:02 PM, Fizzletop said:

Yes, like 7 red errors and 4 yellow... which on first following the documentation stops the VPE menu from being added to Unity menu bar so you cant import a project, which I thought may solve some of the errors where the packages seem to be looking for stuff like lamps... Now I also noticed in the documentation that PinMame has to be installed so I thought I'd try running through the steps backwards and starting with it. So I went to remove the Pinball.Unity.HDRP package and as soon as it was removed the console cleared up and the VPE option got added to the menu bar. 

So the packages I have installed now are Visual Pinball Engine and Visual Pinball Engine (PinMame). And no HDRP pinball package but the Unity project is still HDRP, so all the materials are pink and nothing looks correct plus no ball on test play and the flippers lag horribly, but getting closer.

So I just tried a new Unity URP project and doing the VPE documented steps again of installing PinMame package, which automatically installs Visual Pinball Engine with it. Then I loaded the VPE URP package. After which I loaded an nFozzyExample table from a VPE.10 (x) file that I have. It's working better but of course it isn't very pretty in URP and still some ball spawn problems on play.

So back to the HDRP project, here's what's poping up, with or without a table loaded in an HDRP scene.

Capture6.thumb.PNG.f666eac609f7569b0692e514bb53e663.PNG

Try updating your build of Unity in the hub and update your project, fixed a similar problem for me

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...
On 4/16/2022 at 12:11 AM, JoeAD said:

This looks fantastic, Correct me if I'm wrong, but once a table is published in Unity, only the original creator can edit the published Unity version, unless they also share project code.

 

No, the goal is to use a publication format that can be loaded at runtime but also re-imported into the editor. GitHub issue about that is here.

Link to comment
Share on other sites

  • 2 weeks later...

Hello Forum

 

I'm completely new here and have a few questions. To explain first ...

I'm a c++ developer working in HPC and I had an idea that it would be nice to build a pinball machine using a large flat screen and then writing a simulator for it to do the play - having seen apps on my phone like Zen studios pinball, I thought, it could work quite well and would be much better than having an actual pinball machine since - moving parts - breakage - maintenance - etc etc. Ability to create multiple tables and load them.

(I have many years of OpenGL experience, so the graphics ought to be easy, the physics, not hard, but getting the bumpers and stuff to work well would require a lot of tweaking). (I remember playing a pinball simulation on the Apple ][ when I was young, can't remember what it was called though, butt it was awesome at the time).

 

Before I start on this, I thought I'd look on github to see if there are any open source projects for pinball simulations and I discovered not only that they exist, but that people have been building virtual pinball cabinets for years. I had no idea this was a thing. (I'm ashamed to say that I genuinely thought I'd had a new idea!). I played pinball a lot at university in the 80s (I'm old) - and often wondered about making a pinball simulator.

 

I read about several projects and it seems like the VPE project is most actively developed (please correct me if I'm mistaken). So ...

I work on linux, using c++ and haven't touched a windows machine in quite a few years, (C# reallly? OMG) - but - yesterday, I installed unity/hub on my machine (ubuntu 22.04 based -which turns out to be annoying for your stuff) - installed dotnet (after several failed attempts), cloned the git repos as described in the developer setup, compiled them and then successfully imported 3 projects into unityhub (assets/engine/hdrp). So far so good. (I have setup MAME on a raspberry pi in the past, but had no idea pinMAME existed - nice - actual ROMs from old machines).

 

When I open one of the projects I see a fancy editor and there are lists of assets like bumpers etc, but they don't look interesting yet.

 

So - now I'm kind of stuck - I will spend some time looking at demos in unity - since I have no clue how it works yet and don't know how to create scenes and render them - but are there any more tutorial out there for VPE that describe how to go about loading a table and experimenting with rendering and that sort of thing -- I should do more searching online, but after getting a dev setup that appears to work, I'm ready to start experimenting and too lazy to look any more. Thought I ask for help here and then after a day out, hopefully see some answers and have a look tonight.

 

The videos and things I've seen of tables like the terminator one (which I remember playing a long time ago) look fabulous. Great work. I'll checkout the issues on github and once I feel capable, I'll see if I can start on something useful - first step is to be able to load a table and edit/render it ...)

 

Any help/tips gratefully received. Cheers..

Link to comment
Share on other sites

Awesome, and welcome!

 

I'm sure by now you've come across Visual Pinball, which is the de-facto standard for open source pinball simulation (and what VPE is based on). However, as you surely discovered, it runs on Windows only (although @jsm174 recently got a mac build somewhat running).

 

In terms of usability, VPE is a bit of a mess right now, because we started building tables and are moving stuff from one repo to another in order to re-organize things. So you have to grab the right branches if you wanna get started.

 

This will hopefully be solved next week, when I finish the asset browser and merge all the changes. If you're on Discord, ping me, then I can walk you through what needs to be done if you wanna get started immediately.

 

Cheers!

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...