diff --git a/docs/bastelstube/arma-reforger.md b/docs/bastelstube/arma-reforger.md index 7b67efec..6f4a4b08 100644 --- a/docs/bastelstube/arma-reforger.md +++ b/docs/bastelstube/arma-reforger.md @@ -95,3 +95,23 @@ IEntity entity = GetGame().GetWorld().FindEntityByName("MyEntity"); ``` Screenshot 2023-10-14 120009 +## Spectator +See GRAD Spectator for implementation details: https://github.com/gruppe-adler/GRAD-Spectator +```c# +// Get players entity position +vector pos = GetGame().GetPlayerController().GetControlledEntity().GetOrigin(); + +// Change position to be above and behind the entity +pos[2] = pos[2] - 4; +pos[1] = pos[1] + 3; + +// Enable specator by spawning the spectator entity at the given position +EntitySpawnParams params = new EntitySpawnParams(); +params.Transform[3] = pos; +Resource r = Resource.Load("{E1FF38EC8894C5F3}Prefabs/Editor/Camera/ManualCameraSpectate.et"); +IEntity spectator = GetGame().SpawnEntityPrefab(r, GetGame().GetWorld(), params); + +// Disable specator by deleting spectator entity +SCR_EntityHelper.DeleteEntityAndChildren(spectator); +``` +