Announcement

Collapse
No announcement yet.

Dead Player Remains in Scene After Respawn

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

    Dead Player Remains in Scene After Respawn

    In my game, when the player dies and then respawns, you can still see his dead body for a few seconds before it disappears. Is there a way to make the player's body disappear immediately before the next respawn? I'm extending off UTGame.

    The enemy bots also remain around for a few seconds after death but this is totally fine. It's just the player I want to deal with.

    #2
    You should be able to just call Destroy() on the Pawn when it enters the Dying state if it's controlled by a player. You didn't specify whether or not you want other players to still be able to see a players body or not, so I'm assuming you don't want them to see the body because that's easier to do. This should do the trick:

    Code:
    class NewUTPawn extends UTPawn;
    
    simulated State Dying
    {
    ignores OnAnimEnd, Bump, HitWall, HeadVolumeChange, PhysicsVolumeChange, Falling, BreathTimer, StartFeignDeathRecoveryAnim, ForceRagdoll, FellOutOfWorld;
    
    	simulated function BeginState(Name PreviousStateName)
    	{
    		local bool bDestroyPawn;
    
    		/* check this before call to Super.BeginState() because Pawn will
    		    be detached from Controller afterwards */
    		if ( Controller != None && Controller.bIsPlayer )
    			bDestroyPawn = true;
    		else
    			bDestroyPawn = false;
    
    		Super.BeginState(PreviousStateName);
    
    		// If Pawn was controlled by a player, then destroy it
    		if (bDestroyPawn)
    			Destroy();
    	}
    }
    You're going to have to make sure your extended UTGame class uses this new extended UTPawn as the default pawn class as well. There's a variable in UTGame which will allow you to do this called DefaultPawnClass, which can be set in default properties of your extended UTGame class.

    Comment


      #3
      Originally posted by evr View Post
      You should be able to just call Destroy() on the Pawn when it enters the Dying state if it's controlled by a player. You didn't specify whether or not you want other players to still be able to see a players body or not, so I'm assuming you don't want them to see the body because that's easier to do. This should do the trick:

      Code:
      class NewUTPawn extends UTPawn;
      
      simulated State Dying
      {
      ignores OnAnimEnd, Bump, HitWall, HeadVolumeChange, PhysicsVolumeChange, Falling, BreathTimer, StartFeignDeathRecoveryAnim, ForceRagdoll, FellOutOfWorld;
      
      	simulated function BeginState(Name PreviousStateName)
      	{
      		local bool bDestroyPawn;
      
      		/* check this before call to Super.BeginState() because Pawn will
      		    be detached from Controller afterwards */
      		if ( Controller != None && Controller.bIsPlayer )
      			bDestroyPawn = true;
      		else
      			bDestroyPawn = false;
      
      		Super.BeginState(PreviousStateName);
      
      		// If Pawn was controlled by a player, then destroy it
      		if (bDestroyPawn)
      			Destroy();
      	}
      }
      You're going to have to make sure your extended UTGame class uses this new extended UTPawn as the default pawn class as well. There's a variable in UTGame which will allow you to do this called DefaultPawnClass, which can be set in default properties of your extended UTGame class.

      My game is a typical single player FPS, so I dont want the body to be seen at all after respawn. I see your code is creating a new pawn which extend UTPawn. My custom player already does that, so is there a way to simply edit my pawn code? I'm still fairly new with UnrealScript so I'm hoping you can help me figure this out? Thanks!

      Comment


        #4
        RagdollLifespan=0.0

        Comment


          #5
          Originally posted by gaz661 View Post
          RagdollLifespan=0.0
          Changing this Ragdoll value affects both the bot and player. I tried adding this RagdollLifespan=0.0 into my custom pawn class but it didn't work. Is there a way to make this work only for the player?

          Comment


            #6
            if you extend pawn then maybe your problem is in the controller code, check the dead state in the playercontroller.

            Comment


              #7
              Originally posted by reverrb View Post
              My custom player already does that, so is there a way to simply edit my pawn code?
              Which pawn class are you extending from?

              Comment


                #8
                Originally posted by evr View Post
                Which pawn class are you extending from?
                I'm extending UTPawn Class

                Comment


                  #9
                  Here is my Pawn code:

                  Code:
                      class TTSPawn extends UTPawn;
                  
                  var(NPC) class NPCController;
                  
                  
                  defaultproperties
                  
                  {
                  
                  WalkingPct=+0.4
                  
                  CrouchedPct=+0.4
                  
                  BaseEyeHeight=38.0
                  
                  EyeHeight=38.0
                  
                  GroundSpeed=400.0
                  
                  AirSpeed=440.0
                  
                  WaterSpeed=220.0
                  
                  DodgeSpeed=200.0
                  
                  DodgeSpeedZ=295.0
                  
                  AccelRate=2048.0
                  
                  JumpZ=322.0
                  
                  CrouchHeight=29.0
                  
                  CrouchRadius=21.0
                  
                  WalkableFloorZ=.75
                  
                  AlwaysRelevantDistanceSquared=+1960000.0
                  
                  //InventoryManagerClass=class'UTGame.UTInventoryManager'
                  
                   
                  //ControllerClass=class'TTSGame.TTSPlayerController'
                  
                  NPCController=class'TTSGame.TTSPlayerController'
                  
                   
                  
                  MeleeRange=+20.0
                  
                  bMuffledHearing=true
                  
                   
                  
                  Buoyancy=+000.99000000
                  
                  UnderWaterTime=+00020.000000
                  
                  bCanStrafe=True
                  
                  bCanSwim=true
                  
                  RotationRate=(Pitch=20000,Yaw=20000,Roll=20000)
                  
                  MaxLeanRoll=2048
                  
                  AirControl=+0.35
                  
                  DefaultAirControl=+0.35
                  
                  bCanCrouch=true
                  
                  bCanClimbLadders=True
                  
                  bCanPickupInventory=True
                  
                  bCanDoubleJump=true
                  
                  SightRadius=+3000.0
                  
                   
                  
                  FireRateMultiplier=5.0
                  
                   
                  
                  MaxMultiJump=3
                  
                  MultiJumpRemaining=10
                  
                  MultiJumpBoost=-95.0
                  
                   
                  
                  SoundGroupClass=class'UTGame.UTPawnSoundGroup'
                  
                   
                  
                  TransInEffects(0)=class'UTEmit_TransLocateOutRed'
                  
                  TransInEffects(1)=class'UTEmit_TransLocateOut'
                  
                   
                  
                  MaxStepHeight=35.0
                  
                  MaxJumpHeight=69.0
                  
                  MaxDoubleJumpHeight=87.0
                  
                  DoubleJumpEyeHeight=43.0
                  
                  SuperHealthMax=9000
                  
                  
                  Begin Object Name=WPawnSkeletalMeshComponent
                  
                  bOwnerNoSee=false
                  
                  End Object
                  
                  Name="Default__TTSPawn"
                  
                  }

                  Comment


                    #10
                    Just put it like this:

                    Code:
                        class TTSPawn extends UTPawn;
                    
                    var(NPC) class NPCController;
                    
                    simulated State Dying
                    {
                    ignores OnAnimEnd, Bump, HitWall, HeadVolumeChange, PhysicsVolumeChange, Falling, BreathTimer, StartFeignDeathRecoveryAnim, ForceRagdoll, FellOutOfWorld;
                    
                    	simulated function BeginState(Name PreviousStateName)
                    	{
                    		local bool bDestroyPawn;
                    
                    		/* check this before call to Super.BeginState() because Pawn will
                    		    be detached from Controller afterwards */
                    		if ( Controller != None && Controller.bIsPlayer )
                    			bDestroyPawn = true;
                    		else
                    			bDestroyPawn = false;
                    
                    		Super.BeginState(PreviousStateName);
                    
                    		// If Pawn was controlled by a player, then destroy it
                    		if (bDestroyPawn)
                    			Destroy();
                    	}
                    }
                    
                    defaultproperties
                    
                    {
                    
                    WalkingPct=+0.4
                    
                    CrouchedPct=+0.4
                    
                    BaseEyeHeight=38.0
                    
                    EyeHeight=38.0
                    
                    GroundSpeed=400.0
                    
                    AirSpeed=440.0
                    
                    WaterSpeed=220.0
                    
                    DodgeSpeed=200.0
                    
                    DodgeSpeedZ=295.0
                    
                    AccelRate=2048.0
                    
                    JumpZ=322.0
                    
                    CrouchHeight=29.0
                    
                    CrouchRadius=21.0
                    
                    WalkableFloorZ=.75
                    
                    AlwaysRelevantDistanceSquared=+1960000.0
                    
                    //InventoryManagerClass=class'UTGame.UTInventoryManager'
                    
                     
                    //ControllerClass=class'TTSGame.TTSPlayerController'
                    
                    NPCController=class'TTSGame.TTSPlayerController'
                    
                     
                    
                    MeleeRange=+20.0
                    
                    bMuffledHearing=true
                    
                     
                    
                    Buoyancy=+000.99000000
                    
                    UnderWaterTime=+00020.000000
                    
                    bCanStrafe=True
                    
                    bCanSwim=true
                    
                    RotationRate=(Pitch=20000,Yaw=20000,Roll=20000)
                    
                    MaxLeanRoll=2048
                    
                    AirControl=+0.35
                    
                    DefaultAirControl=+0.35
                    
                    bCanCrouch=true
                    
                    bCanClimbLadders=True
                    
                    bCanPickupInventory=True
                    
                    bCanDoubleJump=true
                    
                    SightRadius=+3000.0
                    
                     
                    
                    FireRateMultiplier=5.0
                    
                     
                    
                    MaxMultiJump=3
                    
                    MultiJumpRemaining=10
                    
                    MultiJumpBoost=-95.0
                    
                     
                    
                    SoundGroupClass=class'UTGame.UTPawnSoundGroup'
                    
                     
                    
                    TransInEffects(0)=class'UTEmit_TransLocateOutRed'
                    
                    TransInEffects(1)=class'UTEmit_TransLocateOut'
                    
                     
                    
                    MaxStepHeight=35.0
                    
                    MaxJumpHeight=69.0
                    
                    MaxDoubleJumpHeight=87.0
                    
                    DoubleJumpEyeHeight=43.0
                    
                    SuperHealthMax=9000
                    
                    
                    Begin Object Name=WPawnSkeletalMeshComponent
                    
                    bOwnerNoSee=false
                    
                    End Object
                    
                    Name="Default__TTSPawn"
                    
                    }

                    Comment


                      #11
                      Thanks evr, it works perfectly.

                      Comment

                      Working...
                      X