UE4 c 建立剛體Cube

2022-06-18 09:36:08 字數 1232 閱讀 6655

tcubeactor.h

#pragma once

#include "coreminimal.h"

#include "gameframework/actor.h"

#include "runtime/engine/classes/components/staticmeshcomponent.h"

#include "tcubeactor.generated.h"

uclass()

class tvivimovedemo3_api atcubeactor : public aactor

;

tcubeactor.cpp

#include "tcubeactor.h"

// sets default values

atcubeactor::atcubeactor()

// called when the game starts or when spawned

void atcubeactor::beginplay()

// called every frame

void atcubeactor::tick(float deltatime)

重點在於把cube提公升為rootcomp,否則建立出來cube永遠在v(0,0,0)點,即使actor點位置動態改變cube絕對位置也不隨actor改變

加乙個cube,開啟物理開關

一些問題記錄

可以使用

ustaticmeshcomponent * cubemesh = findcomponentbyclass();

cubemesh->setsimulatephysics(true);

開啟關閉物理

如果tcubebp中物理沒開啟,可以直接通過setactorlocation設定cube位置(rootcomp被修改為cube後)

如果tcubebp中物理已經開啟,那麼動態關掉物理後cube物理效果是沒了,但是不能再通過setactorlocation設定位置,原因未知

UE4C 建立列舉

目錄 一 目的 1 想 ue4使用c 建立列舉變數適用於c 與藍圖 二 參考 1 ue4使用c 建立列舉變數適用於c 與藍圖 三 注意 1 c 類最好是actor型別,發現gamemodebase型別我在場景中沒有找到 四 操作 1 新建actor的c 類mygamemodebase.h 1 myg...

UE4 C 使用反射

使用 ufunction rightfunc this findfunction fname text onrightmousepressed if rightfunc processevent rightfunc,nullptr 藍圖直接使用藍圖物件根據方法名取得方法 注意 onrightmous...

Ue4C 程式設計 總結篇

通過前面的一系列文章,已經將遊戲的基礎組成要素已經講完了,當然,都是單機的,不涉及網路部分。通過前面的一系列文章,我想製作乙個簡單的遊戲demo也不難了吧。umg是製作遊戲介面乙個十分簡便,強大的模組,它是由封裝自slate。slate有興趣的可以看下官方文件,是純用 編寫介面的,我更喜歡視覺化的u...