Announcement

Collapse
No announcement yet.

Converting Blueprints to C++ code

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

    Converting Blueprints to C++ code

    Hello,

    I am new to UE, not new to programming, I graduate from a Software Engineering degree in a few weeks. I was wondering if there was any good resource I can use to make the process of converting blueprints to C++ any easier? i.e this type of node is this way, this other type of node you code this way, etc

    Any guidance would be greatly received!

    #2
    What I found for myself is that manual converting is much easier than using the "File -> Developer -> Convert to C++" Function in the Blueprint Window.
    That generated code is very unreadable bloated with extra state stuff...

    So in my oppinion it depends on what you want to achieve...
    • If you want to use Blueprints but have better performance --> Use Blueprint Nativization while cooking
    • If you are just curious how it would look like... --> Forget about it... as it is not worth the work in my oppinion
    • If you want to refactor something from Blueprints to C++ --> Do it manually (most of the stuff is exactly named like in the Blueprints)
      • only Datatypes have some additional Prefixes like A (Actor), U (Object or Component), F (Struct or Enum)
      • and sometimes for some methods you need to know where it comes from originally. Because Blueprints hide that sometimes like UGameplayStatics::GetAllActorsOfClass in C++ where in Blueprint you just need to type GetAllActorsOfClass
    But if you want to get back to point 2...
    Just Create two new Unreal Projects.
    • one with the ThirdPerson Character Blueprint Template
    • the other one with the ThirdPerson Character C++ Template
    Then compare

    Starter Resources:
    https://forums.unrealengine.com/deve...ing-references

    Easy (uncomplete) Example:

    C++:
    Code:
    void ALightSwitchCodeOnly::OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
    {
        if (OtherActor && (OtherActor != this) && OtherComp)
        {
             PointLight1->ToggleVisibility();
        }
    }
    
    void ALightSwitchCodeOnly::OnOverlapEnd(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
    {
        if (OtherActor && (OtherActor != this) && OtherComp)
        {
            PointLight1->ToggleVisibility();
        }
    }
    Blueprint:
    Last edited by DarklinkFighter; 04-19-2018, 09:25 AM.

    Comment


      #3
      I cannot see that "File->Developer->Convert to C++" option, where can i find it?

      Comment


        #4
        1- Do you really have to do so much defensive programming with if otherActor, otherComp, etc... I fail to see how you could collide with something that is not an actor and/or that has no primitive component.

        2- Don't do too much blueprint to C++ refactoring, it will have the side effect of making you realize how short a complex blueprint graph can be in C++

        Comment


          #5
          I don't see this option either. I didn't start a C++ project. I started a Blueprint project. Is it possible to convert my blueprints to C++ now and how?

          Comment


            #6
            You have to open a blueprint first and you will see the menu.
            Click image for larger version

Name:	Untitled.png
Views:	1529
Size:	118.7 KB
ID:	1688667

            Comment

            Working...
            X