Page 1 of 1

spectate distance

Posted: November 6th, 2011, 9:48 pm
by boblol0909
Perhaps have spectate like /spec player distance, so that we could follow a little behind them. Personally I think it makes it easier to see when following someone a few blocks out.

Re: spectate distance

Posted: November 8th, 2011, 4:53 am
by Jonty800
I'd love this for my /possess code, is it even possible?

Re: spectate distance

Posted: November 8th, 2011, 5:29 am
by fragmer
Solution #1: You can keep a log of player's last few positions (speedhack detection code in Player.Networking.cs already does it), and use the position from a few seconds ago. If you want to get fancy, traverse the position log to find the most-recent location that is neither too close nor too far. Calculate the vector from spectator's position to target's current position to get the pitch/yaw for the player. You get to both retrace the target's path, and observe them from 3rd-person.

Solution #2: Get the vector of the target's point-of-view (POV) by using Position.R/L. Set vector length to be the spectate distance (something like 128 units / 4 blocks will do). Copy the target's rotation/look to the spectator. You get an over-the-shoulder view.

Of course, both solutions may teleport the spectator into blocks. You may have to do raycasting from target to spectator to dynamically zoom in/out to avoid running into buildings.