spectate distance

Post all ideas and suggestions for fCraft here
Post Reply
User avatar
boblol0909
SupOP
Offline
Posts: 314
Joined: June 24th, 2011, 10:27 pm

spectate distance

Post 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.

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: spectate distance

Post by Jonty800 »

I'd love this for my /possess code, is it even possible?
You cannot use certain BBCodes: [img].

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: spectate distance

Post 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.

Post Reply