Unreal 4 C + + programming experience Summary

Source: Internet
Author: User

Use UE4 to develop FPS games for nearly 1.5 of the time. With a growing understanding of UE4. The previous programming concept has changed a lot. Write it down and make a record

1, add functionality for actor or create component encapsulation feature

Recently in the writing of a sense of control function, according to the direction of the motion controller to determine the direction of the movement of the role. Whether jumping or not. When I start using UE4, I put the function in the character class, gradually the function of character class more and more, Maintenance is also complicated. And the character class is included in many files, each time the declaration of the character class needs to be reproduced to compile many files, the development efficiency becomes lower. When creating component to encapsulate the somatosensory control function, the code becomes cohesive, The character class only needs to hook up with this componnent to provide functionality. When you develop this component, compiling this component is a great speed to compile. So using component to develop functional advantages is obvious.

2. Use the Blueprintcallable,blueprintimplementableevent function to debug in the Blueprint

Adding blueprintcallable to a function can be easily called in a blueprint, and a function with Blueprintimplementableevent can be implemented in a blueprint, then a variable is plotted, or a debug graphic is drawn. Call the Debugdrawline series function.

3, add Ublueprintfunctionlibrary function

The functions in Ublueprintfunctionlibrary can be called globally in the blueprint, and the commonly used functions can be written into it to improve the development efficiency. For example, use meta = (Worldcontext = "Worldcontextobject") Tags can pass the current context object in the Blueprint

Uclass ()classShootergame_api ushooterblueprintfunctionlibrary: Publicublueprintfunctionlibrary{//get the other playersUfunction (blueprintpure, meta = (Worldcontext ="Worldcontextobject"), Category ="Player")    Staticashootercharacter* Getotherplayer (uobject* worldcontextobject, ashootercharacter*Player);} Ashootercharacter* Ushooterblueprintfunctionlibrary::getotherplayer (uobject* worldcontextobject, ashootercharacter*Player) {    if(Uworld* world = gengine->Getworldfromcontextobject (Worldcontextobject)) {         for(Tactoriterator<ashootercharacter> it (world); it; + +it) {            if(*it! =Player) {                return*it; }        }    }    returnnullptr;}

Unreal 4 C + + programming experience Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.