• UE4C++(1)添加组件


    这个是.h里的代码

    #pragma once
    
    #include "CoreMinimal.h"
    #include "GameFramework/Pawn.h"
    #include "Components/StaticMeshComponent.h"
    #include "SphareBase.generated.h"
    
    UCLASS()
    class TEXTGAME_API ASphareBase : public APawn
    {
        GENERATED_BODY()
    
    public:
        // Sets default values for this pawn's properties
        ASphareBase();
            //添加组件,设置宏为引擎到处可编辑,蓝图改写没问题
        UPROPERTY(EditAnywhere, BlueprintReadWrite)
            UStaticMeshComponent * SphereMesh;
    
    
    protected:
        // Called when the game starts or when spawned
        virtual void BeginPlay() override;
    
    public:    
        // Called every frame
        virtual void Tick(float DeltaTime) override;
    
        // Called to bind functionality to input
        virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
    
    };

    这个是.cpp里面的代码

    #include "SphareBase.h"
    
    // Sets default values
    ASphareBase::ASphareBase()
    {
         // Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
        PrimaryActorTick.bCanEverTick = true;
    
        SphereMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SphereBase"));//创建组件方法
        SphereMesh->SetSimulatePhysics(true);//设置物理属性开启
    }
    
    // Called when the game starts or when spawned
    void ASphareBase::BeginPlay()
    {
        Super::BeginPlay();
        
    }
    
    // Called every frame
    void ASphareBase::Tick(float DeltaTime)
    {
        Super::Tick(DeltaTime);
    
    }
    
    // Called to bind functionality to input
    void ASphareBase::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
    {
        Super::SetupPlayerInputComponent(PlayerInputComponent);
    
    }
  • 相关阅读:
    配置了configuration.xml之后提示找不到映射关系
    alibaba maven地址
    Linux通过FTP上传文件到服务器
    JS模拟PHP的sleep
    PHP设置会话(Session)超时过期时间实现登录时间限制[转]
    JavaScript with JSONPath
    用于解析通过JS的escape函数加密过的数据
    IDC、ICP、ISP区别
    zTree通过指定ID找到节点并选中
    运动轨迹[转]
  • 原文地址:https://www.cnblogs.com/tilyougogannbare666/p/13452943.html
Copyright © 2020-2023  润新知