Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 NinjaRubberBand · Nov 25, 2013 at 11:39 AM · physicsmaterialball

Make my ball ONLY bounche up

I made a small ball game with the new 2d functions. Ive made some platforms, and the player which is the ball. i added physic material to my ball, so it constantly bounches. But when it hits the edge of my platform colliders it bounches to the side. (Imagine if you bounched a ball in real life into the edge of a table) How do i make it stop during that?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by fafase · Nov 25, 2013 at 11:41 AM

Constrain the rigidbody to move only in the y direction so that bouncing in x direction is not considered.

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 NinjaRubberBand · Nov 25, 2013 at 11:45 AM 0
Share

I know how to do that in original rigidbody, but i can't find the constrants on 2d rigidbody.

avatar image fafase · Nov 25, 2013 at 11:49 AM 0
Share

oh ok. Well, indeed I do not see any constrain, bit I see velocity. So you could set the x velocity to 0 when hitting the sides of your game.

avatar image NinjaRubberBand · Nov 25, 2013 at 11:56 AM 0
Share

Do i need to script the velocity?

avatar image fafase · Nov 25, 2013 at 12:00 PM 0
Share

it is already in the rigidbody component.

You could do that:

 void OnCollisionEnter(Collision col)
 {
    if(col.gameObject.tag == "Side"){
       Vector3 vel = rigidbody.velocity;
       vel.x = 0;
       rigidbody.velocity = vel;
    }
 }

it also depends on how you move your object, if you launch the ball with initial velocity and then you let the engine do then it should be fine.

avatar image NinjaRubberBand · Nov 25, 2013 at 12:06 PM 0
Share

Im scripting java, so i can't fix the bugs in your script. but it says: .Assets/EdgeFail.cs(1,6): error CS0116: A namespace can only contain types and namespace declarations

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

16 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

Related Questions

Simulating the graphics of a rolling 3D ball in a 2D game 2 Answers

Player-controlled rigidbody ball sometimes slowing down for no reason 0 Answers

How can I show trajectory of a bouncing ball OnCollisionEnter/OnCollisionExit? 0 Answers

Ball jump on collision problem 1 Answer

UnityEditor > Assign a Physics Material from asset folder to colliders component of objects 1 Answer


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