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 itsmealex100 · Mar 04, 2015 at 08:03 PM · c#movementbounce

2D bounce not working

Hi there, I cannot seem to get game objects to bounce off walls the way I want them too. The walls have a boxcollider2d and BouncyBox physics material. The Objects (blue Squares) have a boxcollider2d and rigidbody2d on them, gravity set to 0.

The objects are spawned at random from the top of the screens with a movement script attached to them.

 rb.velocity = new Vector2 (1,-y);


currently this is what happens

alt text

Whereas I need each box to move more freely bouncing from wall to wall before going off the bottom of the screen. Like the this,

alt text

bounce2.png (18.2 kB)
bounce.png (31.2 kB)
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 tebandesade · Mar 04, 2015 at 08:57 PM

Hi! Is the movement script an Updated function? Or just want it starting? Y tried with this script, it just gets an object between to edge colliders, cero gravity to bounce between the two colliders.

 public GameObject c;
 private Rigidbody2D test;
 // Use this for initialization
 void Start () 
 {
      test = c.GetComponent<Rigidbody2D>();


 }
 
 // Update is called once per frame
 void Update () 
 {
     test.AddForce (Vector2.right);
 }

And also changed the bouncy configuration of the material. To do this just double click the material and input some value in bounciness.

Comment
Add comment · Show 2 · 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 itsmealex100 · Mar 05, 2015 at 12:57 AM 0
Share

It's in FixedUpdate at the moment. I tried you script, the problem is that now it only goes directly right, not down. I'm thinking I need something that will change the direction of the cube upon collision so that it heads in the opposite direction until it collides with the other wall and so on.
Just not sure how to do this.

avatar image tebandesade · Mar 18, 2015 at 06:45 PM 0
Share

It shouldn't do that if the physics engine is working properly. Double check the mass of the ball, and the bounciness of the material. Also, try beginning the the force with .AddForce (new Vector2 (5, -5)); This will create a new vector that will add force the right but also down, so a diagonal will be formed

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

21 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

Related Questions

Making a bubble level (not a game but work tool) 1 Answer

Avoid character bouncing off of obstacles 0 Answers

Distribute terrain in zones 3 Answers

Avoid character bouncing off of obstacles 1 Answer

Multiple Cars not working 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