• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by kunddizzle · Feb 10, 2010 at 02:22 PM · physicspinball

How to make Pinball functionality?

Hi

Im experimenting with a little Pinball Game in the Unity Physics...

I made a nice little frame, a ball with rigidbody and gravity.

But i cant figure out how to make my flipper and how to add force to the ball when there is an collision.. and give the ball the right velocity and direction..

currently my flipper is just a Cube, and i tried with rotating, i tried adding force to the flipper but with out any luck..

I need an idea :)

Thx

Comment
duck
Thom Denick
vekariya30

People who like this

3 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

  • Sort: 
avatar image
Best Answer

Answer by duck · Feb 10, 2010 at 02:51 PM

For the ball-flipper interaction, you shouldn't need to explicitly add force to the ball. Really you just need to rotate the flipper by adding a short but strong burst of torque to it, while also having it strictly constrained so that it only moves within the small angle that flippers generally do.

You could do all this with a configurable joint, and set it up so that your script just sets the target rotation of the flipper when you press the controls. See this question for more information: "keyboard controlled configurable joint"

If you rotate the flipper at a fast enough speed, the ball will be thrown or rebounded off the flipper appropriately by the physics engine without you having to explicitly apply a force to the ball yourself. You might want to use AddForce for other items around the pinball table such as the springs and bouncers.

If you want the flippers to be the traditional pinball flipper shape, you will need to use a custom mesh imported from a 3d app. You'll probably also want use the MeshCollider component, and have it use this same mesh (or a simplified version) as the collision mesh. You will also need to make sure the flipper model's origin is positioned correctly - i.e. at the centre of where it would be attached to its axle in real life - so that when you apply torque, it rotates around the correct location.

You may also find that you need to decrease the fixed timestep, since in pinball the ball and flippers can move very fast compared with the size of objects that they can collide with. Reducing the size of the fixed timestep means that the physics are calculated with higher accuracy, and so there is less chance of the ball passing right through interpenetrating an object too far to give an accurate response.

Comment
runevision
efge
kunddizzle
Narven
Thom Denick
Soviut
superlol
rnddev365
vekariya30

People who like this

9 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by GeorgeRigato · Apr 20, 2011 at 07:54 PM

I'm doing the same experiment to learn somethings about unity.

Some hints I managed to find out:

  • Don't tilt the table to get gravity. Insted go to Edit / Project Settings / Physics and add the proper gravity to create the effect. in my case the Y gravity remained the same, and I added "-4,21" at Z axis (as the top of my table is in the positive part of Z axis) to create a 45 inclination effect (I think!). So Things of my table don't get messed up with weird X-axis roations

  • Add the Icy material to the "floor" of your table. The walls are a separate object from my table floor. It will ease so much your ball (pinbal ball please!) movement. In another way, the ball will lose traction, so it will spin less, as a marble ball would in a iced plane. Not the best solution (if there is another one), but it easily solves the problem.

  • Add bouncy material in everything else inside the table, and the ball. It prevents you from manually adding forces for the collisions. let the Unity do the hard work.

My issues:

  • The flippers are also killing me. I tried the hinge joint for some days now, but it bounces and passes the max and min angles, so it's kinda goofy. So i saw now the configurable joint hint. But it looks so complicated to setup. The way Duck says it, looked simple. But we gotta do what we gotta do right? If i manage to setup this config joint I'll save it forever.

  • My ball launcher got a spring joint and a addforce script. The force pulls down the cube, the spring pulls up and collides with the ball. Ball got launched. great! The problem? Well, after the first launch, the spring gets "loose", and the cub do not returns the original position. A little backwards (-Z axis really) and the next launch dont get the same ammount of energy to the ball which gets only half way up the launching tube.

Hope the tips help you.

Cheers.

Comment
efge
BinaryByron

People who like this

2 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by erikblue88 · Aug 19, 2013 at 06:42 PM

Maybe you should check these videos:

http://www.youtube.com/watch?v=Yaxb1LhRQ_U http://www.youtube.com/watch?v=fRfbDruTgeA http://www.youtube.com/watch?v=y-sNKwBg60g

Comment
BerggreenDK

People who like this

1 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BerggreenDK · Jul 10, 2014 at 12:45 AM 0
Share

wonderful and easy to understand tutorial and the link for downloading the project is under the description. Great stuff!

avatar image

Answer by user-10673 (google) · Mar 24, 2011 at 01:44 PM

I'm doing my pinball game in unity. So... I had some problems with the ball x flipper interaction.. I added a flipper and it rotates when I press a key (I made a script for it). When I release the key, it goes back to the initial state. Like a flipper should work.. :P I don't know if it will be the right way to explain it, but when the flipper collides with the ball, it just push the ball a bit and the ball stay in the place. (For testing purposes, I set rotation zero in all axis). What I was expecting is that the ball goes rolling in the table after the collision.

Note: I selected the ball in runtime to see the properties, and the rotation is changing in all axis after the collision, but the position doesn't change.

the base of the table is a cube.. with no physic material..

I'm wondering if somebody has a tip for me to try.

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image 5argon · Dec 06, 2016 at 04:43 AM 0
Share

This is indeed pretty late reply, but I came across this thread while searching for how to do pinball.

You are not supposed to modify any of the Transform property (position, rotation) directly after it is under RigidBody system. I once rotate my flipper directly like that too, the result is the collision will work but no force will be applied to the ball since you did not put any force into the flipper to begin with.

Change the flipper to hinge joint or something, then make it spin up by applying force. That way the force will be transferred to the ball on collision automatically.

avatar image

Answer by NejoFTW · Mar 13, 2017 at 06:56 AM

a bit late but... https://www.youtube.com/watch?v=y7WgV8-yfcI

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Increase force of JointSpring? 0 Answers

Trouble with pinball simulation - pinball passes through flippers. 1 Answer

PINBALL: Ball colliding problems 1 Answer

Pinball bumper only works once 1 Answer

How to make pinball flipper 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges