harfang3d / dogfight-sandbox-hg2

Air to air combat sandbox, created in Python 3 using the HARFANG 3D 2 framework.
GNU General Public License v3.0
161 stars 48 forks source link

After all the missiles on the aircraft were launched, they were not reconfigured in subsequent environmental resets #79

Open cjmdd opened 12 months ago

cjmdd commented 12 months ago

After all the missiles on the aircraft were launched, they were not reconfigured in subsequent environmental resets. We tried to add the following codes to the fit_missile function in MissileDevice Class and the reset function in Aircraft Class but it was still unsuccessful. Print and display all as None.

def fit_missile(self, missile, slot_id):
    nd = missile.get_parent_node()
    nd.GetTransform().SetParent(self.slots_nodes[slot_id])
    # print("Fit Missile"+str(slot_id)+" "+str(pos.x)+" "+str(pos.y)+" "+str(pos.z))
    missile.reset(hg.Vec3(0, 0, 0), hg.Vec3(0, 0, 0))
    self.missiles[slot_id] = missile
    self.missiles_total.append(missile) %%%%%%we add global missiles to reconfigure them when all missiles are fired.

def reset(): %%%%%%we add%%%%%%%%%%%% md=self.get_device("MissilesDevice") n_m=md.num_slots for i in range(n_m): mmd=md.missiles_total[i] nmd=md.missiles[i] if nmd is None: md.missiles[i] = mmd# reset in there

        if position is not None:
            nmd.reset(position, rotation)
        else:
            nmd.reset(hg.Vec3(0, 0, 0), hg.Vec3(0, 0, 0))
ErkMkd commented 11 months ago

Use the Machine.rearm() function to reset the missiles. Each missile is assigned to its aircraft, even when it's fired.