Page MenuHomeFeedback Tracker

SelectSpectator and UpdateSpectatorPosition not working as expected
Assigned, UrgentPublic

Description

I tried to create a system, which would allow a player to spectate another player anywhere on the map. I tried to use it with the GetGame().SelectSpectator() method and I create my own Camera for it, which also spawns on the client at the correct position, but the network bubble is still at the old player position. I don't want to teleport the player near the other one for various reasons as a workaround. Also GetGame().UpdateSpectatorPosition() does not work here.

When I am near the other player, it all works fine. Just when I'm outside the network bubble, it stops working

Update: I also saw, that there is the DayZSpectator Camera class, which I changed for my LBSpectatorCamera to check if my Camera is the reason, but still the same behaviour.

Details

Severity
Block
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce

Create a camera Class in 4_World like this:

class LBSpectatorCamera extends Camera
	
	static LBSpectatorCamera currentCamera;
	
	private float m_SendUpdateAcc = 0.0;

	void LBSpectatorCamera()
	{
		SetEventMask( EntityEvent.FRAME );
		currentCamera = this;
		Print("Created LBSpectatorCamera");
	}
	override void EOnFrame( IEntity other, float timeSlice )
	{
		super.EOnFrame(other, timeSlice);
		if (!IsActive())
			Delete();
		
		
		if (m_SendUpdateAcc > 0.5)
		{
			vector position = GetPosition();
			GetGame().UpdateSpectatorPosition(position);
			m_SendUpdateAcc = 0;
			Print("Sending Position Update: " + position);
		}
		
		m_SendUpdateAcc = m_SendUpdateAcc + timeSlice;
	}
}

And also mod the PlayerBase class like this

modded class PlayerBase {

	void NotifySpectateFinished() {
		GetGame().SelectPlayer(GetIdentity(), this);
		GetGame().RPCSingleParam(null, LBmaster_RPCs.SPECTATE_END, new Param1<bool>(true), true, GetIdentity());
	}
	
	void NotifySpectateStart(PlayerBase target) {
		PlayerIdentity identity = GetIdentity();
		vector pos = target.GetPosition();
		GetGame().SelectPlayer(identity, null);
		GetGame().SelectSpectator(identity, "LBSpectatorCamera", pos);
		GetGame().UpdateSpectatorPosition(pos);
		GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SendDelayedNotifySpectateStart, 200, false, target, identity);
	}
	
	void SendDelayedNotifySpectateStart(PlayerBase target, PlayerIdentity identity) {
		GetGame().UpdateSpectatorPosition(target.GetPosition());
		GetGame().RPCSingleParam(target, LBmaster_RPCs.SPECTATE_START, new Param1<bool>(true), true, identity);
	}
	
}

Then call the NotifySpectateStart method from the Server and the Camera will be created there for the player and it also works, but none of the objects around it will spawn and the LBmaster_RPCs.SPECTATE_START will not work, because the Target PlayerBase object has not been created. Also stopping work fine with NotifySpectateFinished. The Camera returns back to the original position and I can move around again

Event Timeline

LBmaster created this task.Mar 14 2023, 8:42 PM
LBmaster updated the task description. (Show Details)Mar 14 2023, 8:45 PM
LBmaster edited Steps To Reproduce. (Show Details)Mar 14 2023, 9:03 PM
LBmaster updated the task description. (Show Details)Mar 14 2023, 9:11 PM
Geez changed the task status from New to Assigned.Mar 17 2023, 9:41 AM

for me personally it would be enough to just be able to manipulate the players network bubble position through the PlayerIdentity class with something like proto native void SetNetworkBubblePosition(vector position); to overwrite the position to a certain location as like the player would stand there to see items and players around (must be called by the server obviously). and a proto native bool ResetNetworkBubblePosition(), which returns true if the position was overwritten or false if the position was not overwrittien (Also maybe add a method to get the current location and get if it's currently overwritting without having to disable it, but they don't seem to be that needed). Also the PlayerBase of the player remains at it's old position and should still be synced with the server to prevent any issues arrising when deleting the PlayerBase of the player, because he is out of the range of the network bubble. It would also be cool if the VON location would be changed to the same location to allow interacting with other players like the admin is at this position

This would allow to make some cool mods and enhance mods like admin tools, which implement ESPs and having to workaround this issue by teleporting the player around. This would also make them fully invisible for hackers to catch them, because some hackers might notice an admin watching from the edge of the network bubble to check if they are hacking. Also the admins would be able to view bases without having to teleport there. Also implementing a spectating system for players would be easily possible then. Otherwise the Admin would have the be teleported very close to also see items on the ground

f3dm added a subscriber: f3dm.Oct 10 2023, 5:22 AM
f3dm added a comment.Oct 10 2023, 5:24 AM

Same problem.
I'm creating an admin tool controlled by ingame chat. When i'm trying to spectate another player, camera moves to his position, works in free mode, but i can't see even that player (don't talking about all other stuff), because network bubble is still on my character's position.
Hope to get solution. Thanks.