mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 05:51:20 +00:00
Minor addition toe SpectatorCamera. Added three chase modes to lazy follow. 0: Catch up until tracer is centered again. 1: Same but don't move if tracer isn't moving (camera moving when character is not is jarring). 2: Stop chasing if tracer is closer than lagdistance. Game modes benefit from a 'center camera' button but that doesn't have to be hard-baked into the engine.
This commit is contained in:
parent
7fbb4cd06c
commit
c3ca564cfc
1 changed files with 14 additions and 10 deletions
|
@ -132,10 +132,12 @@ class AimingCamera : SecurityCamera
|
||||||
class SpectatorCamera : Actor
|
class SpectatorCamera : Actor
|
||||||
{
|
{
|
||||||
|
|
||||||
double lagdistance;
|
bool chasingtracer;
|
||||||
bool chasing_tracer;
|
double lagdistance; // camera gives chase (lazy follow) if tracer gets > lagdistance away from camera.pos
|
||||||
|
int chasemode; // 0: chase until tracer centered, 1: same but only when tracer is moving, 2: stop chase if tracer within lagdistance
|
||||||
property lagdistance : lagdistance;
|
property lagdistance : lagdistance;
|
||||||
property chasing_tracer : chasing_tracer;
|
property chasingtracer : chasingtracer;
|
||||||
|
property chasemode : chasemode;
|
||||||
|
|
||||||
default
|
default
|
||||||
{
|
{
|
||||||
|
@ -145,8 +147,9 @@ class SpectatorCamera : Actor
|
||||||
+NOINTERACTION
|
+NOINTERACTION
|
||||||
RenderStyle "None";
|
RenderStyle "None";
|
||||||
CameraHeight 0;
|
CameraHeight 0;
|
||||||
SpectatorCamera.chasing_tracer false;
|
SpectatorCamera.chasingtracer false;
|
||||||
SpectatorCamera.lagdistance 0.0;
|
SpectatorCamera.lagdistance 0.0;
|
||||||
|
SpectatorCamera.chasemode 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(double dist, double yaw, double inpitch, int inflags)
|
void Init(double dist, double yaw, double inpitch, int inflags)
|
||||||
|
@ -181,25 +184,26 @@ class SpectatorCamera : Actor
|
||||||
{
|
{
|
||||||
Vector3 distvec = tracer.pos - pos;
|
Vector3 distvec = tracer.pos - pos;
|
||||||
double dist = distvec.length();
|
double dist = distvec.length();
|
||||||
if((dist <= 4 && chasing_tracer) || lagdistance <= 0.0) // Keep tracer centered on screen
|
if((dist <= 4 && chasingtracer) || lagdistance <= 0.0) // Keep tracer centered on screen
|
||||||
{
|
{
|
||||||
SetOrigin(tracer.pos, true);
|
SetOrigin(tracer.pos, true);
|
||||||
chasing_tracer = false;
|
chasingtracer = false;
|
||||||
}
|
}
|
||||||
else // Lazy follow tracer
|
else // Lazy follow tracer
|
||||||
{
|
{
|
||||||
if(dist >= 2*lagdistance)
|
if(dist >= 2*lagdistance)
|
||||||
{
|
{
|
||||||
SetOrigin(tracer.pos, true);
|
SetOrigin(tracer.pos, true);
|
||||||
chasing_tracer = false;
|
chasingtracer = false;
|
||||||
}
|
}
|
||||||
else if(dist > lagdistance && !chasing_tracer) chasing_tracer = true;
|
else if(dist > lagdistance && !chasingtracer) chasingtracer = true;
|
||||||
|
|
||||||
if(chasing_tracer)
|
if(chasingtracer)
|
||||||
{
|
{
|
||||||
speed = tracer.vel.xy.length()/dist;
|
speed = tracer.vel.xy.length()/dist;
|
||||||
if(speed == 0.0) speed = tracer.speed/dist;
|
if((speed == 0.0) && (chasemode == 0)) speed = tracer.speed/dist;
|
||||||
SetOrigin(pos + 2*distvec*speed, true);
|
SetOrigin(pos + 2*distvec*speed, true);
|
||||||
|
if(chasemode > 1) chasingtracer = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue