How to Buffet an object floating in space?

I have a couple of projects where i really need a ragdoll free floating in space, but sort of constrained to the center of the screen, a spring joint should handle the hovering, and i will set the projects gravity to 0.

what can i use to let the player wave the mouse past him or use the arrows to buffet him around like it were space winds... a soft, invisible push

Its a fixed camera looking at a centred astronaut.

One way:

  • Turn off gravity
  • Write code to detect when the mouse pointer hits the astronaut. This is done with Raycast.
  • When the mouse pointer hits the astronaut, apply a force to the astronaut in the direction the mouse was moving when it first touched. (You can also make the force strength be proportional to the mouse speed if you want.)

That's the basic idea. There are all sorts of tweaks you could do, depending how you want it to work. For instance you could apply the force every frame for as long as the mouse is over the astronaut and/or the mouse button is pressed. You will probably want the astronaut's movement to be dampened so that it slows down whenever the pushing stops. Etc.