With the following code, I either get a straight line or no line at all. I have tried almost the same thing in Unity and I get something that looks like orbiting, but here I get nothing.
How can I fix my code to draw a trajectory?
func _update_trajectory(delta):
line.clear_points()
var line_points = []
var pos = mousePosition
#starting velocity 200 for now
var xAxis=200
var yAxis =200
var vel = Vector2(0,100)
var vecR = sunGravity.position-pos
var gravityForce = (vecR).normalized()
var angle= 0
var lastPos = pos +velocity.normalized()
for i in range(1,MAX_POINTS-1):
line_points.append(pos)
vel+=Rigidbody_test(pos)
lastPos=pos
pos += vel*delta
line.points=line_points
func Rigidbody_test(pos1:Vector2):
var planetPos = sunGravity.position
var dir=planetPos-pos1
var dis = dir.length_squared()
var forceMag=2*g_constant*((sunGravity.mass*currentMass)/dis)
var force =dir.normalized()*forceMag
return force
_update_trajectory
function, but the lines under it are not indented as expected (or you're missing thepass
statement). Regarding the problem, how are you drawing line? Does the inspector show the contents/points of the line changing? \$\endgroup\$