Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set localport to ship:controlpart.
- set sep to 50.
- set sl to 0.
- lock offset to v(0,0,0).
- if target:istype("Vessel") set tVes to target.
- else set tVes to target:ship.
- set fpid to pidloop(3,0.01,0.1,-1,1).
- set tpid to pidloop(fpid:kp,fpid:ki,fpid:kd,-1,1).
- set spid to pidloop(fpid:kp,fpid:ki,fpid:kd,-1,1).
- function rv {
- set rel_v to velocity:orbit - tVes:velocity:orbit.
- if target:istype("Vessel") set fa to target:facing.
- else set fa to target:portfacing.
- set wv_pos to (target:position + offset + fa:vector * sep) - localport:position.
- set wanted_v to wv_pos:normalized * min(sl , (wv_pos:mag * 0.25)^0.5).
- set ve to wanted_v - rel_v.
- }
- set dock to true.
- when true then {
- rv().
- set ship:control:translation to v(-spid:update(time:seconds, vdot(facing:starvector,ve)),-tpid:update(time:seconds,vdot(facing:topvector,ve)),-fpid:update(time:seconds,vdot(facing:vector,ve))).
- return dock.
- }
- lock steering to lookdirup(-target:facing:vector, target:facing:topvector).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement