Skip to content

Commit 85a58be

Browse files
committed
Doc: New Page in Doc: Physics
1 parent 9ce5440 commit 85a58be

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed
15.1 KB
Loading
21.1 KB
Loading
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
uid: physics
3+
title: Physics in VPE
4+
description: VPE's physics engine
5+
---
6+
# Physics Engine
7+
8+
When playing pinball, physics are very important. Playfield elements impact the ball. These elements can not only be changed in size and shape but also how the influence the balls movement, so it's important to be able to control them.
9+
10+
Compared to Visual Pinball, VPE uses the same physics engine for almost all parts of the game, but there are differences.
11+
12+
This document will try to describe the differences to the physics engine at first glance, but will try to describe important aspects of the physics engine when they are needed to understand concepts.
13+
14+
## Introduction and general topics
15+
16+
### Visual Pinball and VPE's physics engine
17+
18+
Some (unsorted) facts about the physics engine:
19+
20+
- running at 1000 Hz plus CCD-iterations
21+
- CCD: uses Continuous Collision Detection for collisions
22+
- Uses a quadtree in a broad phase
23+
- is highly optimized for pinball (i.e. optimizied more for static than dynamic objects)
24+
- translates the objects internally on the playfield into "Colliders" like circles, Lines, Planes, Points, Triangles
25+
- VPE's physics mostly use Unity's DOTS (Data-Oriented Technology Stack) and should therefore be multithreaded (which Visual Pinball is not).
26+
- is by no means a accuraty system to describe physics (no game physics engine is). Physics in Pinball are much more complicated as one might think. Imagine a spinning ball hitting a flexible rubber -> should the spin vanish, get reversed, get conservated, and if, how much? - It depends...
27+
28+
### Different coordinate systems
29+
30+
In VPE's (and Visual Pinball) physics engine, a different coordinate system is used as it is used in unity.
31+
32+
For the following explanation, imagine looking at the playfield from above:
33+
In physics engine,
34+
- positive X is right
35+
- positive Y is down (to the drain)
36+
- positive Z is pointing to my eye
37+
38+
In Unity also looking from above onto the playfield:
39+
- positive X is right
40+
- positive Y is pointing to my eye
41+
- positive Z is pointing from the drain into the backglass
42+
43+
## Settings of different components
44+
45+
### Walls and Rubbers
46+
47+
Playfield elemets may have collider components, such as a rubber collider:
48+
[!Rubber Collider](rubber-collider-with-physics-material-asset.png)
49+
In general, you can set
50+
- Elasticity,
51+
- Elasticity Falloff,
52+
- Friction,
53+
- Scatter Angle
54+
55+
Targets, metal wire guides, primitives, ramps, rubbers also have the ability to set a Physics Materials Asset as a preset.
56+
57+
You can create a new Physics Materials Asset in any Asset Folder in the project view by "right click, create, visual pinball, physics material".
58+
59+
A physics material asset has more options compared to the collider components themselves.
60+
[Physics Material Asset](physics-material-asset-with-curves.png)
61+
While you can set the options from above, you also can set curves for elasticity over velocity and friction over velocity.
62+
Many people think the the physics settings and scripts proposed by nFozzy come closest to real pinball.
63+
64+
While nFozzy wrote Visual Basic Scripts which optimized the Visual Pinball physics. While it would be possible to implement exactly the same behaviour as nFozzy proposed in his scripts, VPE deviates from the original implementation slightly:
65+
66+
nFozzy felt the elasticity and elasticity fall-off settings were somewhat limited in simulating the correct behaviors for these objects so he defined new curves for elasticity of objects for different ball speeds:
67+
[nFozzy Rubber Dampening Curve](nfozzy-curve.png)
68+
(original nFozzy curve for a rubber band)
69+
70+
What nFozzy did, was adjusting the XY-velocity of a ball from before collision to a new velocity after collision. According to different speeds, different factors were used for reduction of the velocity.
71+
In the example above: a ball with the speed of approximately 30 (Physics Units per Second) should come out of the collision with slightly less than 80% of it's original speed.
72+
73+
VPE's implementation of this behaviour slightly differs:
74+
- Not the XY-Speed is taken as basis for the calculation, but the perpendicular (normal) speed to the Wall/Target/Rubber.
75+
- Not the XY-Speed is reduced, but only elasticity of the object is overwritten by the value (0.8), thus reducing the perpendicular (normal) bounce of the ball to 80%.
76+
- The velocity of the ball along the target (tangent) is not reduced artificially by the curve, but it may be reduced by friction or scatter-angle.
77+
The reason for this is, that we think that nFozzy just was not able to do so (because in VP-VBS the impact angle is simply not given to the script), and would have done the same.
78+
79+
Nevertheless nFozzy (maybe without wanting to) also reduced friction based effects on the ball.
80+
To take this into account, there is another parameter curve introduced in VPE: Friction over Velocity. It works the same, as the elasticity over velocity curve, but may dampen the friction according to velocity.
81+
82+
83+
### Flipper correction (Part 1, Polarity / Velocity)
84+
-> [Flippers](xref:VisualPinball.Unity.Flippers)
85+
86+
### Flipper correction (Part 2, Flipper Tricks)
87+
(coming soon to VPE (TM))
88+
89+
90+
16.8 KB
Loading

0 commit comments

Comments
 (0)