Jump to content



Photo
* * * * * 1 votes

Getting Ball Position and Velocity

ai interfacing ball parameters

  • Please log in to reply
4 replies to this topic

#1 AutomationClub

AutomationClub

    Neophyte

  • Members
  • Pip
  • 1 posts

  • Flag: Serbia

  • Favorite Pinball: Mr Randall's Pinball

Posted 24 February 2022 - 02:39 AM

Hi,

 

I'm new to this community, but I joined to try and train pinball AI agents digitally. A question I had was how would I approach getting the X and Y positions and velocities of the ball and have it output to a txt file or console?

 

A small side question I have is how do I make the game display windowed? It launches fullscreen by default and I can't seem to figure out how to make it windowed.



#2 Thalamus

Thalamus

    Pinball Wizard

  • Platinum Supporter
  • 4,938 posts

  • Flag: Norway

  • Favorite Pinball: GOT, Alien Star, LOTR, TOM

Posted 24 February 2022 - 04:15 AM

Dim b:b=getballs:debug.print b(0).x & " " & b(0).y & " " & b(0).z

 

start table - press D - gives a console - running the above tells you where the ball is. Several balls - increase the number. DjRobX showed me this one a while back, very useful to find lost balls with.

 

Windowed ? Set graphical interface to windowed instead of fullscreen is a good start, followed by esc I believe ? Been a while since I played on my old desktop machine.


Edited by Thalamus, 24 February 2022 - 04:17 AM.

From now on. I won't help anyone here at VPF. Please ask Noah why that is.


#3 jpsalas

jpsalas

    Grand Schtroumpf

  • VIP
  • 7,171 posts
  • Location:I'm Spanish, but I live in Oslo (Norway)

  • Flag: Norway

  • Favorite Pinball: I like both new and old, but I guess I prefer modern tables with some rules and goals to achieve.



Posted 24 February 2022 - 04:33 AM

It is easy to display the ball X and Y position and velocity since VP and VPX does have some built in functions.

 

The easiest way is to display that position and velocity when the ball goes over a trigger or hit a target is to display it to the debug window. But first you need to do a few things, and it has to do with your second question.

 

First, to run VPX in a window, you need to go to the Menu Preferences > Vide/Graphics Options and remove the "Force exclusive FullScreen Mode" and second you need to choose another resolution for your window from the ones displayed (see picture below):

[attachment=32999:Capture.PNG]

Now you have VPX running in a window. Press ESC to make the window toolbar appear and you can move the window around. Pressing ESC several times will let toggle the toolbar on and off.

 

Now to show the X and Y coordinates and velocity:

 

VP and VPX has a built in function which return those values when the ball hits a trigger or a target (a wall may also return those values).

This will be the easiest way to do it, as a real time will produce too much data.

 

So place some triggers around your table where you want to check the ball speed and coordinates. Place as many triggers you want.

Add an entry in the script for each trigger, for example trigger001 will be like this:

 

Sub trigger001_hit

    debug.print activeball.X

    debug.print activeball.Y

    debug.print activeball.velX

    debug.print activeball.velY

    debug.print " "

End Sub

 

Do the same for all the other triggers.

 

Then run the table and press the key D to open the debug window (or press ESC and choose the debug window from the menu)

When the ball passes over one of the triggers you'll see the data on the debug window.

 

Negative X values means the ball is moving left, and

negative Y values means the ball is moving upwards.

 

There are many other ways to do that, but this I feel it is the easiest way.

  


If you want to check my latest uploads then click on the image below:

 

vp.jpg

 

WIP? Cobra, Nuova Bell and Playbar tables, thanks to akiles50000 redrawings


#4 allknowing2012

allknowing2012

    Pinball Fan

  • Members
  • PipPipPipPip
  • 1,948 posts
  • Location:Waterloo, ON

  • Flag: Canada

  • Favorite Pinball: bucaneer

Contributor

Posted 24 February 2022 - 02:17 PM

Sounds like he might be looking for something like this:
https://www.vpforums...showtopic=41718


* I don't know everything - I just have no life *
testimageNL

 

 

 

#5 Daveo123

Daveo123

    Neophyte

  • Members
  • Pip
  • 2 posts

  • Flag: United States of America

  • Favorite Pinball: Fathom

Posted 21 April 2025 - 11:18 PM

Dim b:b=getballs:debug.print b(0).x & " " & b(0).y & " " & b(0).z
 
start table - press D - gives a console - running the above tells you where the ball is. Several balls - increase the number. DjRobX showed me this one a while back, very useful to find lost balls with.
 
Windowed ? Set graphical interface to windowed instead of fullscreen is a good start, followed by esc I believe ? Been a while since I played on my old desktop machine.







Also tagged with one or more of these keywords: ai, interfacing, ball, parameters