Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Velocity not changing after collisions

Discussion in '2D' started by vdKa, Oct 22, 2019.

  1. vdKa

    vdKa

    Joined:
    Jan 22, 2014
    Posts:
    13


    I want the ball to bounce after collision. I dont understand what is preventing that.

    I try to change:
    velocitytreshold and fixeddeltatime

    Ball:
    Rigidbody 2d:
    Dyanmic
    max 0.1
    drags are 0
    collision : continuous
    Ball.PNG

    Pad:
    Rigidbody 2d:
    kinematic
    Pad.PNG

    both have colliders attached.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    Probably because nothing is moving here. I suspect you're just setting the angle of the flippers which just causes an overlap of the ball which the physics system solves. Essentially you're just teleporting the flipper from one pose to another. Continuous isn't involved because again, nothing is actually moving.

    You need to use Rigidbody2D.MoveRotation, set the angular velocity or add torque. All of these involve the flipper actually moving.
     
    random123random4 and vdKa like this.
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    Also, please don't cross post on multiple forums.
     
    vdKa likes this.
  4. vdKa

    vdKa

    Joined:
    Jan 22, 2014
    Posts:
    13
    Thank you so much. It solved my problem. And now I have another problem. After collision ball moves too fast. How can i set the bouncing after collision. I play with drags and mass but I could not get it done. It is only happens when I slow down the flipper rotation speed. But then the feel is gone.

    PS: Sorry for the duplicate threads. I thought physics forum is better for this post. But cannot delete the older one.
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    All I have to go on is guesswork as you're not actually providing any info on what you're doing just "it solved my problem" ;)

    Maybe if you're using MoveRotation you're moving it from one angle instantly to another or very quickly which means it'll have a very high angular velocity. This will cause the ball to have a high velocity impact (lots of energy). You wouldn't use linear drag for that, you want to control the impact speeds in the first place. Also the "bounce" isn't going to do change this that much. In the end, without more info it's hard to tell you how to tune it.
     
    vdKa likes this.
  6. vdKa

    vdKa

    Joined:
    Jan 22, 2014
    Posts:
    13
    Hi,
    First I was rotating the "transform". Than I rotate "rigidbody" as you said. "It solved my problem" part was for that :D
    I mean, the flippers are colliding exactly how it supposed to be.
    But as you said because of I rotate flippers fast this will cause the ball to have a high velocity impact.
    I changed the Physics2D.maxTranslationSpeed to a lower value to solve it.
     
  7. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    You really shouldn't do that as it affects everything globally. It's far better for you to simply rotate the flippers slower. Anyway, if you've not got many moving pieces then whatever works is good. Just be aware that in the future you might find other things hit that limit too and increasing it breaks the flippers.