Announcement

Collapse
No announcement yet.

Announcing Section #2 for Survival Game - Weapons & Interaction

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

    #61
    Originally posted by Vahid View Post

    and another question is what is difference between these two type of pointer ? both compile fine in STypes.h

    Code:
    TWeakObjectPtr<class ASCharacter> PawnInstigator;
    class ASCharacter* PawnInstigator;
    TWeakObjectPtr is a weak pointer to the character. That means it doesn't hold on to the character in memory. Meaning that if all other pointers are gone except this one, the character will still be deleted from memory. If we were using a regular pointer, it would be kept in memory until this last pointer to the character was removed too.

    To get the pointer from a TWeakObjectPtr is done through .Get() like so: ASCharacter* MyPawn = PawnInstigator.Get() This returns the pointer IF it still exists, so make sure you check for nullptr after (if (PawnInstigator != nullptr) { }) before using it.

    Hope that helps.
    Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-source template)

    Comment


      #62
      Worth adding that you can also do MyPtr.IsValid() on a Weak Object Pointer to check if it is NULL as well (not nullptr, but NULL!)

      Comment


        #63
        Hi thanks for your answer.

        I have another question.

        I don't know why when clients shoots each other or shoots to server this function returns false but when server shoots to other returns true... Why this happens?
        Code:
        bool ASWeaponInstant::ShouldDealDamage (AActor* TestActor) const
        {
        if(TestActor)
        {
         if(GetNetMode() != NM_Client ||
        TestActor ->Role == ROLE_Authority ||
        TestActor->bTearOff)
        {
        return true;
        }
        }
        return false;
        }
        ABC Augmented Reality by UE4
        GooglePlay

        ArchVis VR

        Comment


          #64
          It checks if we are allowed to apply damage, which only happens on the server-side OR when the actor is torn off (bTearOff) from the server OR if the actor has authority to make changes, eg. to take damage.
          Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-source template)

          Comment


            #65
            I know that Tom,
            But when I I test this code on your project everything was Ok server and clients can shoots to each other, but in my project that's code not working I don't know what's wrong in my project, everything is like your project I'm using your project as a learning resources every things is same ... I don't know where I made a mistake.
            ABC Augmented Reality by UE4
            GooglePlay

            ArchVis VR

            Comment


              #66
              I have a doubt that how to control the weapon's force when its bullet hit the actor . i found that when I shoot the bomb, it will move. when i shoot the barrier, it can't move. I did not find where to set the power of weapon hit.

              Comment


                #67
                i have another question about Skeleton socket . Different rifles have different Skeleton root causing the different result when attached to the same socket. how to sovle this problem except modify the source skeleton file? thank u..

                Comment


                  #68
                  Originally posted by liXiang View Post
                  i have another question about Skeleton socket . Different rifles have different Skeleton root causing the different result when attached to the same socket. how to sovle this problem except modify the source skeleton file? thank u..
                  You can rotate the socket after adding it to your skeleton inside the viewer where you added the Socket.
                  Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-source template)

                  Comment


                    #69
                    I also can not get ".generated.h" in STypes.h

                    Comment


                      #70
                      Originally posted by VeyDlin View Post
                      I also can not get ".generated.h" in STypes.h
                      What's the problem? the generated.h files don't need any manual work, the Unreal Header Tool automatically creates these files for you each compile.
                      Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-source template)

                      Comment


                        #71
                        In one of the screenshots, I saw there was some nice blood effect going on. How was this done, exactly? Could you share the textures/particles?
                        -Josh Steinhauer ~ HERO ~ My Blog ~ My Twitter

                        Comment


                          #72
                          Originally posted by joshcamas View Post
                          In one of the screenshots, I saw there was some nice blood effect going on. How was this done, exactly? Could you share the textures/particles?
                          Everything is available in the project files that you can download mate. The blood FX is from the ShooterGame sample, I re-used it for this project too.
                          Game Developer @ LODZERO - My Twitter | tomlooman.com UE4 samples & tutorials | C++ Survival Game (Open-source template)

                          Comment


                            #73
                            Originally posted by Tom Looman View Post
                            What's the problem? the generated.h files don't need any manual work, the Unreal Header Tool automatically creates these files for you each compile.
                            Where did or does it create the STypes.h from? I am trying to understand how to create a file like this but the documentation I have read did not make it clear. I followed some examples and they did not work.. or at least do not work as of 4.12.. maybe something is different

                            I tried to follow this https://answers.unrealengine.com/que...d-structs.html which I thought seemed right and it did not work.

                            Comment

                            Working...
                            X