Announcement

Collapse
No announcement yet.

DetachFromBone() and resulting object location

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    DetachFromBone() and resulting object location

    I coded a vehicle that, instead of mounting WeaponPawns, attaches other vehicles to it. I spawn them in the same way as WeaponPawns and attach them to the carrier vehicle using AttachToBone. Their physics is set to PHYS_Karma.

    When the player tries to exit one, he should "launch" it off of the main vehicle. I tried to do this using DetachFromBone, then setting the detached vehicle's location to

    VehicleBase.Location +
    VehicleBase.GetBoneCoords('passenger1').origin

    and the rotation in the same manner. However, whenever I try to do this in-game, the vehicle simply appears on the ground near where the carrier vehicle was originally summoned.

    Is there any way to place the vehicle at the correct location?

    Will the fact that they are both Karma models and that one is inside the other's collision box make a difference?

    (Sorry for the lack of code. Posting all of it would take quite a bit of space. I will post any pertinent sections when I know which ones they are.)

    #2
    Do you even need to set the location? Detaching it from a bone shouldn't affect its location.

    Comment


      #3
      Yeah, that's what I thought. However, without it, the vehicle just zips straight to the ground (i.e. is instantly relocated there). Here's the code (with SetLocation removed) from the attached vehicle:

      Code:
      function DetachFromVehicle(name WeaponBone)
      {
          if (Level.NetMode != NM_Client)
          {
              VehicleBase.DetachFromBone(self);
      
              //self.SetLocation(VehicleBase.Location + VehicleBase.GetBoneCoords(attachedBone).origin);
              //self.SetRotation(VehicleBase.Rotation + VehicleBase.GetBoneRotation(attachedBone));
          }
      }
      
      function bool KDriverLeave( bool bForceLeave )
      {
          if(bAttached)
          {
                      ONSDropshipCraft(VehicleBase).ReleasePod(self);
                      bAttached=false;
                      return False;
          }
         Super.KDriverLeave(bForceLeave);
      }
      
      function AttachToVehicle(ONSVehicle VehiclePawn, name WeaponBone)
      {
          if (Level.NetMode != NM_Client)
          {
              VehicleBase = VehiclePawn;
              VehicleBase.AttachToBone(self, WeaponBone);
              attachedBone=WeaponBone;
          }
      }
      PS - I just checked: summoned a dropship at my base, flew it across the map, detached one of these - it was placed at my base

      EDIT: heh, had another thought: when I release these, I automatically spawn another on the dropship. IF my positioning worked, it would be spawning right ontop of the just-released one. So, I commented the respawning out... to no avail; they keep jumping to where I summoned the dropship.

      Code:
      simulated function PostNetBeginPlay()
      {
          local int i;
      
          Super.PostNetBeginPlay();
      
          if (Role == ROLE_Authority)
          {
              // Spawn the Passenger Pods
              for(i=0;i<PodSpawn.Length;i++)
              {
                  Pods[i] = spawn(PodSpawn[i].PodClass, self,, Location);
                  Pods[i].AttachToVehicle(self, PodSpawn[i].PodBone);
                  Pods[i].ObjectiveGetOutDist = ObjectiveGetOutDist;
              }
          }
      }
      
      simulated function ReleasePod(ONSDropshipPod rpod)
      {
      local int i;
              for(i = 0; i<Pods.Length; i++)
              {
                    if(Pods[i]==rpod)
                      break;
              }
            rpod.DetachFromVehicle(PodSpawn[i].PodBone);
      
          if (Role == ROLE_Authority)
          {
                    // Spawn New Pod
                  //Pods[i] = spawn(PodSpawn[i].PodClass, self,, Location);
                  //Pods[i].AttachToVehicle(self, PodSpawn[i].PodBone);
                  //Pods[i].ObjectiveGetOutDist = ObjectiveGetOutDist;
          }
      }

      Comment


        #4
        It's WORKING!

        Finally figured out what to do: start with the correct KParams, physics set to PHYS_None, then switch to PHYS_Karma when released (also fiddled with CheckReset - not sure that did anything).

        Now I have a dropship with 6 scorpions people can fire while attached and unlatch from the ship. As an added bonus, you get a daredevil award whenever you release one .

        Comment


          #5
          Eeew - with PHYS_None, the driver's body is not updated. It just hangs there where it first was placed after entering an attached scorpion. When the physics changes to PHYS_Karma, he's back in there. But until then? Dunno, might use Tick to constantly set him in the driver's seat.

          Is there a more elegant solution?

          Comment


            #6
            Could you have the Scorpion's driver in a passenger seat in the main vehicle while it's attached instead?

            Comment

            Working...
            X