Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Object isn't moving the way I want it to move

Discussion in 'Physics' started by svenvanh, Aug 21, 2020.

  1. svenvanh


    Nov 29, 2019
    So I have a bit of a complicated question.
    I have recorded some gameplay and shown some code but my problem is that if I touch a white ball the red ball automatically moves a bit to the left. I just want it to jump away from the green circle (aka planet). I thought
    adding a force in the other direction from the green circle that would do the trick.

    Code (CSharp):
    1. rb.AddForce(((planet.transform.position - transform.position) * -1).normalized * multiplier, ForceMode2D.Impulse);
    Does anyone know how to fix this?