Enabling/disabling an entity?

0

Hi folks,

I'm attempting to enable and disable an entity (with Transform, Static Mesh, Rigid Body Physics and Mesh Collider components) via Lua scripting, using the following code:


GameEntityContextRequestBus.Broadcast.DeactivateGameEntity(entityIdHere);
GameEntityContextRequestBus.Broadcast.ActivateGameEntity(entityIdHere);

However this appears to actually do nothing at all. In Unity or similar this is as simple as setting a property of the entity (like isActive) to true or false via the code, however this isn't possible in LY and even the way to do it through EBuses doesn't seem to work!

All I want to do is remove, and then bring back, this entity in the scene, including visuals and physics.

質問済み 7年前185ビュー
5回答
0
承認された回答

Hello @REDACTEDUSER

I see what you are attempting to do. By calling these EBus methods you would get the Activate() and Deactivate() methods called on GameEntityContextComponent.cpp which doesn't really do much other than connect and disconnect to some buses and resets the AssetCatalog.

To be able to disable and enable entities and their associated components in 1.8, we recommend using the SimpleStateComponent. The SimpleStateComponent allows you to define several states and allows you to assign entities to those states. When a state is enabled all of the entities and the components for each entity is activated, conversely when a state is disabled all of the entities in that state and their components will be deactivated.

Let us know if that helps!

Thanks!

回答済み 7年前
0

Hi @REDACTEDUSER

回答済み 7年前
0

I come here to help, but there isn't enough data to make a focused answer.

I believe he have to post his script then it will be way more clear to understand why it doesn't work.

回答済み 7年前
0

Thanks! @REDACTEDUSER

回答済み 7年前
0

@REDACTEDUSER

回答済み 7年前

この投稿はクローズされています。新しい回答、コメント、投票の追加はできません。

関連するコンテンツ