How to properly move rigid body 2D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sprowk
:warning: Old Version Published before Godot 3 was released.

So far I have been using this script for moving rigid body 2D.

func _integrate_forces(s):
  var lv = s.get_linear_velocity()
  var step = s.get_step()
  #other logic changing lv.x and lv.y
  lv += s.get_total_gravity()*step
  self.set_linear_velocity(lv)

I read that I should not set linear velocity every frame so how and with what can I replace it?