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. Dismiss Notice

Question Causing an object to drift

Discussion in 'Scripting' started by Tigersong, Jun 17, 2022.

  1. Tigersong

    Tigersong

    Joined:
    Aug 11, 2014
    Posts:
    73
    Hello there. I'm making a shooter set in null gravity and have hit a snag. How do I go about setting an object adrift? I assume AddForce is involved, but that's as far as I've gotten.

    Eventually what I want is to have several objects spawn, drift around the scene and collide with players and each other.

    Thank you for your help.
     
  2. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,593
    Not really a Scripting question, more of a Physics one. You just need to set your game's gravity to 0 in your Project Settings, and add RigidBodies to all your objects. Then, if you give them any kind of velocity (including from AddForce as you mentioned), they will drift.
     
  3. Tigersong

    Tigersong

    Joined:
    Aug 11, 2014
    Posts:
    73
    Thanks. I've gotten objects to float upwards; it's a start.