Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

How can I preserve a bouncing ball's velocity?

Discussion in 'Physics' started by gameangel147, Jun 6, 2018.

  1. gameangel147

    gameangel147

    Joined:
    Oct 16, 2016
    Posts:
    21
    My brickbreaker game has a ball and an ability that summons apples to act as extra balls. I gave the ball a circle collider and the apples a polygon collider so that they can rotate as they bounce. Unfortunately they are losing velocity when they collide at a wrong angle or with each other or with the ball.

    With the ball, I only set the velocity when launched and left it at that, as I didn't need to preserve the velocity. I've thought about using "this.rigidbody2D.velcoity.x" and so on to keep the values at what I set them to but it's not working.

    Is there a command or some way to keep their velocity constant?
     
  2. SparrowsNest

    SparrowsNest

    Joined:
    Apr 6, 2017
    Posts:
    271
    In the physics settings or the physics material there's a value for this called bounciness or something, is it set to max?
     
    gameangel147 likes this.
  3. jbaumer6

    jbaumer6

    Joined:
    Mar 12, 2018
    Posts:
    9
    If you are grabbing the velocity from an Update() method, you are going to continually get a new velocity. You'll want to use a bool flag to take a snapshot of the objects velocity where you want it, then apply that value in an Update() method until you don't want it anymore.
     
    gameangel147 likes this.
  4. gameangel147

    gameangel147

    Joined:
    Oct 16, 2016
    Posts:
    21
    It's not. I kept it at just the right amount so that it wouldn't go too fast. Is there a way to increase bounciness in a script?

    Alright, I was just wondering if there was a specific command to deal with that, but that sounds like a simple enough alternative. Since it's an ability, I can just adjust the velocity for the ability's duration.

    Thank you guys!