Search Unity

[Help] Hovering Reflecting Ball Not Working

Discussion in 'Physics' started by DKKnown, Mar 19, 2018.

  1. DKKnown

    DKKnown

    Joined:
    Sep 5, 2017
    Posts:
    1
    Hello there, thx in advance.

    I am working on a 3D game.

    The intend: I want a Ball that is not affected by gravity but can still be manipulated by velocity(rigidbody). This ball is in a closed off room, but can bounce off anything.

    The problem: The ball can float in air quite welll, and i can move it at a speed using in FixedUpdate:

    this.rigidbody.velocity = this.rigidbody.velocity.normalized * Time.deltaTime * 100.0f;

    rigidbody.AddRelativeForce(100.0f * this.transform.forward);


    But the ball just goes into an instant stop when hitting a wall, even though i should reflect its movement:
    this code is triggered OnCollisionEnter,

    this.rigidbody.velocity = Vector3.Reflect(this.rigidbody.velocity, contact.normal);


    Can someone please explain what i am doing wrong?
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    You could instead try giving your ball's collider component a bouncy physics material. That should give you the same result you're looking for.
     
    StickyHoneybuns likes this.