Announcement

Collapse
No announcement yet.

Problems with Pawn (Destroying and Ragdoll)

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

    Problems with Pawn (Destroying and Ragdoll)

    Hi,

    I am currently stuck with this one:
    If a pawn get's killed he should get removed by our game mode when some time passed (round end).

    The current code:

    Code:
       for (TActorIterator<AGameCharacter> ActorItr(GetWorld()); ActorItr; ++ActorItr)
        	{
        		AGameCharacter* CurrentDeadBody = *ActorItr;
        		if (!CurrentDeadBody->GetController())
        		{
        			UE_LOG(LogTemp, Warning, TEXT("I am dead: %s"), *CurrentDeadBody->GetName()); // gets called and prints the right name
        			GetWorld()->DestroyActor(CurrentDeadBody); // does not work
        			CurrentDeadBody->killme(); // Neither this  (just this->Destroy(); on the pawn)
        		}
        			
        	}
    The game is a multiplayer game, but since it gets called from the game mode this should not be a problem, right?

    When this->destroy() is called right after DetachFromControllerPendingDestroy(); within the pawn after taking damage it works.
    I am also unable to go into ragdoll mode. (I almost copied the entire code from the first person example shooter game (AShooterCharacter::OnDeath()))

    The game is at 4.13.2

    I have absolutely no clue right now... :/

    #2
    Ragdolling characters can actually be a bit difficult to set up in Multiplayer, since you want the pawn to 'tear off' and stop replicating movement etc too most likely.

    Check out ShooterGame, it has code that does exactly this

    Comment


      #3
      I already checked that one.
      Seems that I have to destroy the pawn on the server AND on the client ...
      I think I am ending up just copying a lot of the ShooterGame's Character class (but why not ^^)

      I am still unable the remove all the dead corpses (first post)
      Last edited by Th120; 01-10-2017, 09:41 AM.

      Comment


        #4
        Can't destroy them?
        Interesting.
        "CurrentDeadBody->Destroy();" should work.
        Odd.

        As for ragdolling, the default method is to 'tear off' the characters and then enable physics on the character mesh.
        When an actor is torn off, it is destroyed on the server, but remains on any clients it existed on previously - hence, torn off.

        If you do not need dead bodies to be synchronized, this method is the better way of doing things, since it reduces the load on the server.
        This method requires removing the bodies via a message on the game state instead of game mode.

        If you do need them synchronised, well, as TheJamsh mentioned, that is more difficult, though not impossible.
        Rule#21: Be polite, be professional, but have a plan to kill everyone you meet.

        Comment


          #5
          I got some of the code from the shootergame and the ragdoll works now.
          But Destroying does only work if I call a NetMuslticast method (this->Destroy() on the pawn.
          Also one of the models seems to "vibrate" while being in ragdoll (only this, a different one works).

          I have a bigger, strange problem now:

          https://www.dropbox.com/s/t33zyhpmkg...20txt.txt?dl=0 <- log

          I have absolutely no clue why.
          The editor crashes while compiling, but after restarting it seems that everything is compiled correctly.
          Also AttachToProcess with VS does not work.

          Any suggestions?

          // edit:

          Seems to work after doing this in a completely different file (last changed more than 3 months ago):
          Code:
          bool UTODemoList::Initialize()
          {
              Super::Initialize();
          	//ReplayStreamer = FNetworkReplayStreaming::Get().GetFactory().CreateReplayStreamer();
          
              //EnumerateStreamsVersion.Changelist = 0;
              //EnumerateStreamsVersion.NetworkVersion = 0;
          
              //BuildDemoList();
          
              return true;
          }
          Last edited by Th120; 01-10-2017, 04:42 PM.

          Comment

          Working...
          X