添加tickactor,没成功

This commit is contained in:
2025-02-12 00:13:16 +08:00
parent 1e0c4b8d8c
commit a9e87c74bb
6 changed files with 132 additions and 21 deletions
+35
View File
@@ -1,4 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const UE = require("ue");
const puerts_1 = require("puerts");
// 创建一个用于Tick的Actor
class TSTickActor extends UE.Actor {
constructor() {
super(...arguments);
this.lastPrintTime = 0;
}
ReceiveTick(DeltaSeconds) {
super.ReceiveTick(DeltaSeconds);
// 每秒打印一次
this.lastPrintTime += DeltaSeconds;
if (this.lastPrintTime >= 1.0) {
console.log('Tick: ' + this.lastPrintTime.toFixed(2));
this.lastPrintTime = 0;
}
}
// 确保Actor可以Tick
ReceiveBeginPlay() {
super.ReceiveBeginPlay();
this.PrimaryActorTick.bCanEverTick = true;
}
}
console.log('--------------------------entry.ts started2----------------------');
// 获取游戏实例和世界
let gameInstance = puerts_1.argv.getByName("GameInstance");
let world = gameInstance.GetWorld();
// 在场景中生成TSTickActor
let spawnLocation = new UE.Vector(0, 0, 100); // 在高度100的位置生成,避免卡在地面
let spawnRotation = new UE.Rotator(0, 0, 0);
let spawnTransform = new UE.Transform();
spawnTransform.SetLocation(spawnLocation);
spawnTransform.SetRotation(spawnRotation.Quaternion());
let tickActor = UE.GameplayStatics.BeginDeferredActorSpawnFromClass(world, TSTickActor.StaticClass(), spawnTransform);
UE.GameplayStatics.FinishSpawningActor(tickActor, spawnTransform);
console.log('--------------------------TSTickActor spawned----------------------');
//# sourceMappingURL=entry.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../TypeScript/entry.ts"],"names":[],"mappings":";;AAGA,OAAO,CAAC,GAAG,CAAC,mEAAmE,CAAC,CAAA"}
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../TypeScript/entry.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AACxB,mCAAuC;AAEvC,mBAAmB;AACnB,MAAM,WAAY,SAAQ,E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