I try to run a pushback truck as visible AI/MP model. Now, this snippet is from one of those experiments
- Code: Select all
if (getprop("sim/model/pushback/enabled")) {
var pos_truck = me.moorings["local"].position;
var heading=getprop("/orientation/heading-deg");
me.model["local"].remove();
if (getprop("sim/model/pushback/position-norm")>0.95) {
var pos_aircraft = geo.aircraft_position();
var distance=8.35; #correction for tailwheel x-offset from zero point
var course=geo.normdeg(heading+180); #180 deg to get away from the plane
pos_truck.set_lat(pos_aircraft.lat());
pos_truck.set_lon(pos_aircraft.lon());
pos_truck.set_alt(pos_aircraft.alt());
pos_truck.apply_course_distance(course, distance);
print("truck ", pos_truck.lat(), pos_truck.lon());
print("craft ", pos_aircraft.lat(), pos_aircraft.lon());
}
me.model["local"] = geo.put_model(me.model_path, pos_truck, geo.normdeg(heading+180));
}
But what happens is, the truck, which is initially visible from the FG instance, I started it, disappears as soon as "enabled" is set on true. If I comment out the remove-line, I have of course thousands of trucks in the same position and FG crashes, that was to be expected, but they are visible. So ...
- why does the truck go invisible on me id there should be always one left?
- is there a more elegant way to force a model to move instead of remving it and then placing it anew? geo.nas has no hint about a possibility like a move_model.
J.