Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
0
Question by joeeydubu · Jul 03, 2017 at 12:04 PM · 2d gamebreakout

how to freeze a rigidbody onto of another?

hey guys, I am trying to make a 2d breakout sort of spin off and I want to add a little tweak to the gameplay, what I want to add is overtime the ball comes back into contact with the paddle the ball sticks to the paddle, so then you have to click again to fire the ball off again? I am so unsure of how to do it, could someone please show me a code example or explain how I would do this please?

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by IronPig_ · Jul 03, 2017 at 12:15 PM

You should check when they are in contact with OnCollisionEnter2D and if they are you should set the ball's rigidbody 2D to be kinematic and set the paddle to be its parent than when you want to fire it you should unparent it and set it's rigidbody 2D to nonkinematic and apply a force to it.

Comment
Add comment · Show 5 · 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 joeeydubu · Jul 03, 2017 at 12:27 PM 0
Share

thank you for replying and that is somewhat helping, but it still doesn't stick to the paddle? its setting it to kinematic as it hits it but still bouncing around

avatar image IronPig_ · Jul 03, 2017 at 12:33 PM 0
Share

Can I take a look at your code ?

avatar image joeeydubu IronPig_ · Jul 03, 2017 at 12:39 PM 0
Share

sorry to waste your time, but I figured it out! but thank you so much for your help! (:

avatar image IronPig_ · Jul 03, 2017 at 12:53 PM 0
Share

I am happy to help you. :-)

avatar image joeeydubu IronPig_ · Jul 04, 2017 at 09:02 AM 0
Share

hey pigletsoft, sorry to bother you again but I have another question I have it all working very well, but sometimes now when the ball collides with the side of the paddle it still sticks? how could I make it so that enters the game over scene?

I have a collider below the paddle so if the ball goes past the paddle it will touch it and be game over, should I just bring that collider up closer to the paddle so it triggers the game over without attaching to the side? or would there be a good code trick I could use?

or at least ins$$anonymous$$d of triggering the game over when it hits the side, it just doesn't stick to the paddle then bounces into the game over collider? I think that would be a cool way to do it but I am unsure how?

avatar image
0

Answer by joeeydubu · Jul 03, 2017 at 12:05 PM

I am scripting in c# as well

Comment
Add comment · 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

70 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiplying score on a gameobject destroy; only while a button is held 0 Answers

How to fix graphic bugs LoadScene? 0 Answers

im trying to do an immortal state when my player take damage 2 Answers

2D Game Trail renderer 0 Answers

Unity - dragging a RigidBody2D Gameobject by mouse/touch without any lag 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