Camera Not Transitioning Properly

Discussions about Coding and Scripting
Post Reply
User avatar
LannFyre
Skilled
Posts: 233
Joined: Sun Dec 28, 2014 1:10 am
Location: Anubitek

Camera Not Transitioning Properly

Post by LannFyre » Sun Sep 11, 2016 2:04 am

This video explains the whole problem:
Spoiler
Show
I have a third-person camera that is sometimes operated by a zone. I have an option in the zone (bool) that says whether or not the camera should strafeto() a location if true. If not, instantly move to this new location. I know for a fact that the location is getting to the camera (a scripted actor), but I am having a few issues:

> The actor is supposed to adjust a switch statement via a function call in state code once the scripted pawn reaches its location. Instead, I think it is always attempting to move in one spot, as the camera is practically vibrating in place, which is only observable due to the camera being the actor the player views through.

> If the player is given a new set of coordinates via a specific trigger (all that matters out of this is the new location), the camera will then instead begin to move to this new location if it is already in the process of moving.

I also have a zone written up, but for some reason I am noticing that when I touch the zone, I am getting two zone checks each time my pawn either enters or exits the zone, said zone is what tells said player's camera to move. I'm going to have to post both codes (spoiler'd) and a visual demonstration of what I am talking about. This is my first attempt at any zone actors or changing the camera from a pawn to a scripted pawn for the latent functions.

Here is the state code in Camera:
Spoiler
Show

Code: Select all

Begin: 
    if ( LocalPlayer == none && !FindLocalPlayer() )
    {
        Sleep(0.0);
        Goto('Begin');
    }
	if ( LocalPlayer.Health <= 0 )
	{
		self.Velocity = vect(0.0,0.0,0.0);
		self.Acceleration = vect(0.0,0.0,0.0);
	}
    SetPhysics( PHYS_Flying);
CheckViewTarget:
    LocalPlayer.ViewTarget = self;
    LocalPlayer.bBehindView = false;
	self.bBehindView = false;
Move:
	if ( self.Location == NewLoc || CameraMode != CM_MoveTransition )
	{
		bTransitionMoving = false;
	    Velocity = vect(0.0,0.0,0.0);
        Acceleration = vect(0.0,0.0,0.0);
		SetLocation( NewLoc );
		sleep(0.0);
		GoTo('Reset');
	}
	if ( CameraMode == CM_MoveTransition )
	{
		//Velocity = Vector(Rotation) * 100.0;
		//Acceleration = AccelRate * Normal(NewLoc - Location);
		Acceleration = AccelRate * Normal(NewLoc - Location);
		StrafeTo(NewLoc, LocalPlayer.Location);
		//MoveTo(NewLoc, Airspeed);
		sleep(0.0);
		GoTo('Move');
	}
Reset:
	if ( CameraMode == CM_MoveTransition )
	{
		LockMovement();
		CamCueueAdjust();
	}
	sleep(0.0);
	GoTo('Begin');
}

//Unrealscript functions always have a return value, said value is zero'd before function call.
//Meaning, if we return nothing, the function still return False
function bool FindLocalPlayer()
{
    local PlayerPawn P;
    ForEach AllActors (class'PlayerPawn', P)
        if ( ViewPort(P.Player) != none )
        {
            LocalPlayer = P;
            return true;
        }
}

function UnlockMovement()
{
	if ( bCamXAxisLock )
	{
		bTempXLock = true;
		bCamXAxisLock = false;
	}
	if ( bCamYAxisLock )
	{
		bTempYLock = true;
		bCamYAxisLock = false;
	}
	if ( bCamZAxisLock )
	{
		bTempZLock = true;
		bCamZAxisLock = false;
	}
}

Function LockMovement()
{
	if ( bTempXLock )
	{
		bCamXAxisLock = true;
		bTempXLock = false;
	}
	if ( bTempYLock )
	{
		bCamYAxisLock = true;
		bTempYLock = false;
	}
	if ( bTempZLock )
	{
		bCamZAxisLock = true;
		bTempZLock = false;
	}
}

function CamCueueAdjust()
{
	switch CamCueue
	{
		case CM_Track1:
			CameraMode = CM_Track1;
			break;
		case CM_Track2:
			CameraMode = CM_Track2;
			break;
		case CM_CustomCamDistance1:
			CameraMode = CM_CustomCamDistance1;
			break;
		case CM_CustomCamDistance2:
			CameraMode = CM_CustomCamDistance2;
			break;
		case CM_MoveTransition:
			CameraMode = CM_MoveTransition;
		default:
			break;
	}
}
Full camera code:
Spoiler
Show

Code: Select all

//=============================================================================
// RPG_Camera.
// Operates independently now
// There should only be one camera
//=============================================================================
class RPG_Camera extends ScriptedPawn;

//Some dummy Camera values that might be coded at a later date
enum ECamMode
{
	CM_Track1,
	CM_Track2,
    CM_CustomCamDistance1, // Track player relative to "TrackCustomDistance", which sets distance.
	CM_CustomCamDistance2,
	CM_MoveTransition
};
var() ECamMode 	CameraMode;
enum ECamCueue
{
	CM_Track1,
	CM_Track2,
    CM_CustomCamDistance1, // Track player relative to "TrackCustomDistance", which sets distance.
	CM_CustomCamDistance2,
	CM_MoveTransition
};
var() ECamCueue 	CamCueue;
// The visible properties are kept here to allow map save/loading as well as letting the mapper
//  specify the initial camera mode without using a trigger
var PlayerPawn 	LocalPlayer;
var(Sounds) sound Test;
var() float    	CamDistance;
var bool			bTransitionMoving;
var() bool		bCamXAxisLock;
var() bool		bCamYAxisLock;
var() bool		bCamZAxisLock;
var bool			bTempXLock;
var bool			bTempYLock;
var bool			bTempZLock;
var() bool		bRestorePitch;
var() bool		bRestoreYaw;
var() bool		bRestoreRoll;
var bool			bNewLoc;
var float     	TargetDistance;

var vector NewLoc;
var vector adjust;
// These already exist, putting these here for informative purposes:
// var (Movement) rotator DesiredRotation;
// var (Movement) rotator RotationRate;
// var float EyeHeight; //From actor, namely, your player pawn, this is the height offset the player's first person view camera is placed at (don't think you'll be needing this)
// var rotator Rotation; // From actor, namely, your player pawn
// var vector Location; // From actor, namely, your player pawn
var carcass carc;

// Disabling some superclass functions
function ClientDying(name DamageType, vector HitLocation);
function ClientGameEnded();
function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, name damageType);
function Died(pawn Killer, name damageType, vector HitLocation);
event FellOutOfWorld();

//======================================================================================
event PostBeginPlay()
{
    Super.PostBeginPlay();
    //The rotation the mapper uses will be the initial rotation
    DesiredRotation = Rotation;
    ViewRotation = Rotation;
    TargetDistance = CamDistance;
	AccelRate = 1000;
}
//======================================================================================
// CAMERA STATE - ONLY STATE THAT SHOULD BE USED FOR THIS ACTOR
//	> THIS ACTOR'S ONLY JOB IS TO BE USED AS AN EXTERNAL FREE MOVING THIRD PERSON CAMERA
//	[ToDo]: LINEAR INTERPOLATION AND SMOOTHING FRAMES
//	() makes it appear as a selectable InitialState in the editor.
//======================================================================================
auto state Camera
{
	ignores SeePlayer, HearNoise;
	
	function EndState()
	{
		super.EndState();
	}
	
    // Higor: This event is called by the player when viewing this actor in first person view
    event Tick( float DeltaTime )
    {
//		local rotator View;
		local int OldYaw;
		local int OldPitch;
		local int OldRoll;
		
		bCanFire = false;
		SpecialGoal = None;
		SpecialPause = 0.0;

		if ( !bTransitionMoving )
			
		if ( LocalPlayer == none )
			return;
		switch CameraMode
		{
//=============================================================================
            case CM_Track1: // The camera tracks the local player at a fixed x and y point, moving only by it's z axis.
                OldPitch = DesiredRotation.Pitch;
                OldYaw = DesiredRotation.Yaw; // Conserve DesiredRotation's yaw
				OldRoll = DesiredRotation.Roll;
				if ( bCamXAxisLock )
					NewLoc.X = Location.X;
				else if ( !bCamXAxisLock )
					NewLoc.X = LocalPlayer.Location.X - vector(DesiredRotation).X * VSize(Location - LocalPlayer.Location);
				if ( bCamYAxisLock )
					NewLoc.Y = Location.Y;
				else if ( !bCamYAxisLock )
					NewLoc.Y = LocalPlayer.Location.Y - vector(DesiredRotation).Y * VSize(Location - LocalPlayer.Location);
				if ( bCamZAxisLock )
					NewLoc.Z = Location.Z;
				else if ( !bCamZAxisLock )
					NewLoc.Z = LocalPlayer.Location.Z - vector(DesiredRotation).Z * VSize(Location - LocalPlayer.Location);
				DesiredRotation = rotator( LocalPlayer.Location - Location);
				if ( bRestorePitch == true)
					DesiredRotation.Pitch = OldPitch; // Restore pitch
				if ( bRestoreYaw == true)
					DesiredRotation.Yaw = OldYaw; // Restore yaw
				if ( bRestoreRoll == true)
					DesiredRotation.Roll = OldRoll;
                SetLocation( NewLoc );
				SetRotation( DesiredRotation );
                break;
//=============================================================================
            case CM_Track2: // The camera tracks the local player at a fixed x and y point, moving only by it's z axis.
                OldPitch = DesiredRotation.Pitch;
                OldYaw = DesiredRotation.Yaw; // Conserve DesiredRotation's yaw
				OldRoll = DesiredRotation.Roll;
				if ( bCamXAxisLock )
					NewLoc.X = Location.X;
				else if ( !bCamXAxisLock )
					NewLoc.X = LocalPlayer.Location.X - vector(DesiredRotation).X * VSize(Location - LocalPlayer.Location);
				if ( bCamYAxisLock )
					NewLoc.Y = Location.Y;
				else if ( !bCamYAxisLock )
					NewLoc.Y = LocalPlayer.Location.Y - vector(DesiredRotation).Y * VSize(Location - LocalPlayer.Location);
				if ( bCamZAxisLock )
					NewLoc.Z = Location.Z;
				else if ( !bCamZAxisLock )
					NewLoc.Z = LocalPlayer.Location.Z - vector(DesiredRotation).Z * VSize(Location - LocalPlayer.Location);
				DesiredRotation = rotator( LocalPlayer.Location - Location);
				if ( bRestorePitch == true)
					DesiredRotation.Pitch = OldPitch; // Restore pitch
				if ( bRestoreYaw == true)
					DesiredRotation.Yaw = OldYaw; // Restore yaw
				if ( bRestoreRoll == true)
					DesiredRotation.Roll = OldRoll;
                SetLocation( NewLoc );
				SetRotation( DesiredRotation );
                break;
//=============================================================================
            case CM_CustomCamDistance1:
                if ( TargetDistance < CamDistance ) // Interpolate camera distance in a very arbitrary way
                    CamDistance = fMax( CamDistance - LocalPlayer.GroundSpeed * 0.2 * DeltaTime, TargetDistance);
                else if ( TargetDistance > CamDistance )
                    CamDistance = fMin( CamDistance + LocalPlayer.GroundSpeed * 0.2 * DeltaTime, TargetDistance);
                NewLoc = LocalPlayer.Location - vector(DesiredRotation) * CamDistance;
                SetLocation( NewLoc);
                break; 
//=============================================================================
            case CM_CustomCamDistance2:
                if ( TargetDistance < CamDistance ) // Interpolate camera distance in a very arbitrary way
                    CamDistance = fMax( CamDistance - LocalPlayer.GroundSpeed * 0.2 * DeltaTime, TargetDistance);
                else if ( TargetDistance > CamDistance )
                    CamDistance = fMin( CamDistance + LocalPlayer.GroundSpeed * 0.2 * DeltaTime, TargetDistance);
                NewLoc = LocalPlayer.Location - vector(DesiredRotation) * CamDistance;
                SetLocation(NewLoc);
                break; 
//=============================================================================
			case CM_MoveTransition:
				bTransitionMoving = true;
				UnlockMovement();
				break;
//=============================================================================
            default:
                break;
        }
    }
//=============================================================================
// Latent Code
//=============================================================================
Begin: 
    if ( LocalPlayer == none && !FindLocalPlayer() )
    {
        Sleep(0.0);
        Goto('Begin');
    }
	if ( LocalPlayer.Health <= 0 )
	{
		self.Velocity = vect(0.0,0.0,0.0);
		self.Acceleration = vect(0.0,0.0,0.0);
	}
    SetPhysics( PHYS_Flying);
CheckViewTarget:
    LocalPlayer.ViewTarget = self;
    LocalPlayer.bBehindView = false;
	self.bBehindView = false;
Move:
	if ( self.Location == NewLoc || CameraMode != CM_MoveTransition )
	{
		bTransitionMoving = false;
	    Velocity = vect(0.0,0.0,0.0);
        Acceleration = vect(0.0,0.0,0.0);
		SetLocation( NewLoc );
		sleep(0.0);
		GoTo('Reset');
	}
	if ( CameraMode == CM_MoveTransition )
	{
		//Velocity = Vector(Rotation) * 100.0;
		//Acceleration = AccelRate * Normal(NewLoc - Location);
		Acceleration = AccelRate * Normal(NewLoc - Location);
		StrafeTo(NewLoc, LocalPlayer.Location);
		//MoveTo(NewLoc, Airspeed);
		sleep(0.0);
		GoTo('Move');
	}
Reset:
	if ( CameraMode == CM_MoveTransition )
	{
		LockMovement();
		CamCueueAdjust();
	}
	sleep(0.0);
	GoTo('Begin');
}

//Unrealscript functions always have a return value, said value is zero'd before function call.
//Meaning, if we return nothing, the function still return False
function bool FindLocalPlayer()
{
    local PlayerPawn P;
    ForEach AllActors (class'PlayerPawn', P)
        if ( ViewPort(P.Player) != none )
        {
            LocalPlayer = P;
            return true;
        }
}

function UnlockMovement()
{
	if ( bCamXAxisLock )
	{
		bTempXLock = true;
		bCamXAxisLock = false;
	}
	if ( bCamYAxisLock )
	{
		bTempYLock = true;
		bCamYAxisLock = false;
	}
	if ( bCamZAxisLock )
	{
		bTempZLock = true;
		bCamZAxisLock = false;
	}
}

Function LockMovement()
{
	if ( bTempXLock )
	{
		bCamXAxisLock = true;
		bTempXLock = false;
	}
	if ( bTempYLock )
	{
		bCamYAxisLock = true;
		bTempYLock = false;
	}
	if ( bTempZLock )
	{
		bCamZAxisLock = true;
		bTempZLock = false;
	}
}

function CamCueueAdjust()
{
	switch CamCueue
	{
		case CM_Track1:
			CameraMode = CM_Track1;
			break;
		case CM_Track2:
			CameraMode = CM_Track2;
			break;
		case CM_CustomCamDistance1:
			CameraMode = CM_CustomCamDistance1;
			break;
		case CM_CustomCamDistance2:
			CameraMode = CM_CustomCamDistance2;
			break;
		case CM_MoveTransition:
			CameraMode = CM_MoveTransition;
		default:
			break;
	}
}

defaultproperties
{
	Physics=PHYS_Flying
	bBlockActors=false
	bBlockPlayers=false
	bCollideActors=false
	bCollideWorld=false
	bProjTarget=false
	bCanStrafe=true
	CollisionHeight=0.0
	CollisionRadius=0.0
//	fovangle=30.0//150.0
	AccelRate=1000
	bHidden=true
	bEdShouldSnap=True
	DrawType=DT_Sprite
	Texture=Texture'Engine.S_Camera'
	Test=Sound'RPG_Sounds.RPG_LaserFire'
	Style=STY_Masked
}
The zone actor, if at all relevant though it seems to work somewhat properly and I don't think should be the focus:
Spoiler
Show

Code: Select all

//=============================================================================
// RPG_CameraOpZone.
//=============================================================================
class RPG_CameraOpZone extends ZoneInfo;

var RPG_Camera   ActiveCamera;

enum ECamMode
{
	CM_Track1,
	CM_Track2,
    CM_CustomCamDistance1,
	CM_CustomCamDistance2,
	CM_MoveTransition
};
var ECamMode	NewCameraMode;

enum EVect1CamMode
{
	CM_None,
	CM_Track1,
	CM_Track2,
    CM_CustomCamDistance1,
	CM_CustomCamDistance2
};
var() EVect1CamMode	Vect1CamMode;

enum EVect2CamMode
{
	CM_None,
	CM_Track1,
	CM_Track2,
    CM_CustomCamDistance1,
	CM_CustomCamDistance2
};
var() EVect2CamMode	Vect2CamMode;

enum EVect3CamMode
{
	CM_None,
	CM_Track1,
	CM_Track2,
    CM_CustomCamDistance1,
	CM_CustomCamDistance2
};
var() EVect3CamMode	Vect3CamMode;

enum EVect4CamMode
{
	CM_None,
	CM_Track1,
	CM_Track2,
    CM_CustomCamDistance1,
	CM_CustomCamDistance2
};
var() EVect4CamMode	Vect4CamMode;

var RPG_PlatformPawn LocalPlayer;

//var() byte		TriggerGroupID; // Used for when CameraSwitchers are to be used as a trigger.  Used to prevent triggers from constantly firing.
//var() float		TriggerGroupScanDist;
//var() float		SmoothFactor; // To be described later
var byte			SharedCameraID;
var() float		TrackCustomDistance;
var() rotator		NewRotation;
var vector		NewCamLoc; // For fixed or X,Y track mode, if Zero, use camera's current

//var() bool		bSmoothTransition;
var() bool		bCamXAxisLock;
var() bool		bCamYAxisLock;
var() bool		bCamZAxisLock;
var() bool		bRestorePitch;
var() bool		bRestoreYaw;
var() bool		bRestoreRoll;
var() bool		bInstantLocTransition;

//=====================================
// What SharedCameraID will be set to
//=====================================
var(RPG_CamLoc1) byte		CamID1;
var(RPG_CamLoc2) byte		CamID2;
var(RPG_CamLoc3) byte		CamID3;
var(RPG_CamLoc4) byte		CamID4;

//=====================================
// New Camera Position
//=====================================
var(RPG_CamLoc1) vector		CamAngle1;
var(RPG_CamLoc2) vector		CamAngle2;
var(RPG_CamLoc3) vector		CamAngle3;
var(RPG_CamLoc4) vector		CamAngle4;

//=====================================
// Position Pawn Needs To Be In For Camera Position Change
//=====================================
var(RPG_CamLoc1) vector		MoveCamVector1;
var(RPG_CamLoc2) vector		MoveCamVector2;
var(RPG_CamLoc3) vector		MoveCamVector3;
var(RPG_CamLoc4) vector		MoveCamVector4;

//=====================================
// Should Position Be Checked
//=====================================
var(RPG_CamLoc1) bool		bCheckCamVector1;
var(RPG_CamLoc2) bool		bCheckCamVector2;
var(RPG_CamLoc3) bool		bCheckCamVector3;
var(RPG_CamLoc4) bool		bCheckCamVector4;

//=====================================
// Checks Player's X Coordinate
//	Pos: If Player X is Greater Than Position X
//	Neg: If Player X Is Less Than Position X
//=====================================
var(RPG_CamLoc1) bool		bCheckPlayer_X_Pos_1;
var(RPG_CamLoc2) bool		bCheckPlayer_X_Pos_2;
var(RPG_CamLoc3) bool		bCheckPlayer_X_Pos_3;
var(RPG_CamLoc4) bool		bCheckPlayer_X_Pos_4;
var(RPG_CamLoc1) bool		bCheckPlayer_X_Neg_1;
var(RPG_CamLoc2) bool		bCheckPlayer_X_Neg_2;
var(RPG_CamLoc3) bool		bCheckPlayer_X_Neg_3;
var(RPG_CamLoc4) bool		bCheckPlayer_X_Neg_4;

//=====================================
// Checks Player's Y Coordinate
//=====================================
var(RPG_CamLoc1) bool		bCheckPlayer_Y_Pos_1;
var(RPG_CamLoc2) bool		bCheckPlayer_Y_Pos_2;
var(RPG_CamLoc3) bool		bCheckPlayer_Y_Pos_3;
var(RPG_CamLoc4) bool		bCheckPlayer_Y_Pos_4;
var(RPG_CamLoc1) bool		bCheckPlayer_Y_Neg_1;
var(RPG_CamLoc2) bool		bCheckPlayer_Y_Neg_2;
var(RPG_CamLoc3) bool		bCheckPlayer_Y_Neg_3;
var(RPG_CamLoc4) bool		bCheckPlayer_Y_Neg_4;

//=====================================
// Checks Player's Z Coordinate
//=====================================
var(RPG_CamLoc1) bool		bCheckPlayer_Z_Pos_1;
var(RPG_CamLoc2) bool		bCheckPlayer_Z_Pos_2;
var(RPG_CamLoc3) bool		bCheckPlayer_Z_Pos_3;
var(RPG_CamLoc4) bool		bCheckPlayer_Z_Pos_4;
var(RPG_CamLoc1) bool		bCheckPlayer_Z_Neg_1;
var(RPG_CamLoc2) bool		bCheckPlayer_Z_Neg_2;
var(RPG_CamLoc3) bool		bCheckPlayer_Z_Neg_3;
var(RPG_CamLoc4) bool		bCheckPlayer_Z_Neg_4;

//=============================================================================
// General functionality
//=============================================================================
event ActorEntered( actor Other )
{
	local Triggers Trigger;
	
	super.ActorEntered( Other );
	if ( Pawn(Other)!=None && Pawn(Other).bIsPlayer )
	{
		LocalPlayer = RPG_PlatformPawn(Other);
		ForEach ZoneActors ( class'Triggers', Trigger )
		{
			if ( Trigger.tag == self.tag )
			{
				if ( Trigger.bCollideActors != true )
				{
					Trigger.SetCollision(true, false, false);
				}
			}
		}
		if ( (Other.IsA('RPG_PlatformPawn') ) && (LocalPlayer != none) && (ViewPort(LocalPlayer.Player) != none) )
		{
			if ( HasActiveCamera() )
			{
				if ( Self.Event != '' )	
					TriggerEvent( Event, self, Pawn(Other) );
				if ( SharedCameraID != LocalPlayer.OldCamID )
				{
					CheckPlayerLoc();
					SetCameraMode();
					//SetTimer(1, false);
				}
				else if ( SharedCameraID == LocalPlayer.OldCamID ) // If the current camera is set to the mode a camera switcher is set to, that isn't CM_Fixed,
				{
					return;
				}
			}
		}
	}
}

// @Override
event ActorLeaving( actor Other )
{
	local Triggers Trigger;

	super.ActorLeaving( Other );
	if ( Pawn(Other)!=None && Pawn(Other).bIsPlayer )
	{
		//SetTimer(0.5, false);
		CheckPlayerLoc();
		SetCameraMode();
		if ( --ZonePlayerCount==0 )
		{
			ForEach ZoneActors ( class'Triggers', Trigger )
			{
				if ( Trigger.event == self.tag )
				{
					if ( Trigger.bCollideActors != false )
					{
						Trigger.SetCollision(false, false, false);
					}
				}
			}
		}
	}
}

//=============================================================================
// Check local player's location
//=============================================================================
function CheckPlayerLoc()
{
	if ( bCheckCamVector1 == true )
	{
		if ( bCheckPlayer_X_Pos_1 && (LocalPlayer.Location.X >= MoveCamVector1.X) )
		{
			NewCamLoc = CamAngle1;
			SharedCameraID = CamID1;
		}
		if ( bCheckPlayer_X_Neg_1 && (LocalPlayer.Location.X <= MoveCamVector1.X) )
		{
			NewCamLoc = CamAngle1;
			SharedCameraID = CamID1;
		}
		if ( bCheckPlayer_Y_Pos_1 && (LocalPlayer.Location.Y >= MoveCamVector1.Y) )
		{
			NewCamLoc = CamAngle1;
			SharedCameraID = CamID1;
		}
		if ( bCheckPlayer_Y_Neg_1 && (LocalPlayer.Location.Y <= MoveCamVector1.Y) )
		{
			NewCamLoc = CamAngle1;
			SharedCameraID = CamID1;
		}
		if ( bCheckPlayer_Z_Pos_1 && (LocalPlayer.Location.Z >= MoveCamVector1.Z) )
		{
			NewCamLoc = CamAngle1;
			SharedCameraID = CamID1;
		}
		if ( bCheckPlayer_Z_Neg_1 && (LocalPlayer.Location.Z <= MoveCamVector1.Z) )
		{
			NewCamLoc = CamAngle1;
			SharedCameraID = CamID1;
		}
	}
	if ( bCheckCamVector2 == true )
	{
		if ( bCheckPlayer_X_Pos_2 && (LocalPlayer.Location.X >= MoveCamVector2.X) )
		{
			NewCamLoc = CamAngle2;
			SharedCameraID = CamID2;
		}
		if ( bCheckPlayer_X_Neg_2 && (LocalPlayer.Location.X <= MoveCamVector2.X) )
		{
			NewCamLoc = CamAngle2;
			SharedCameraID = CamID2;
		}
		if ( bCheckPlayer_Y_Pos_2 && (LocalPlayer.Location.Y >= MoveCamVector2.Y) )
		{
			NewCamLoc = CamAngle2;
			SharedCameraID = CamID2;
		}
		if ( bCheckPlayer_Y_Neg_2 && (LocalPlayer.Location.Y <= MoveCamVector2.Y) )
		{
			NewCamLoc = CamAngle2;
			SharedCameraID = CamID2;
		}
		if ( bCheckPlayer_Z_Pos_2 && (LocalPlayer.Location.Z >= MoveCamVector2.Z) )
		{
			NewCamLoc = CamAngle2;
			SharedCameraID = CamID2;
		}
		if ( bCheckPlayer_Z_Neg_2 && (LocalPlayer.Location.Z <= MoveCamVector2.Z) )
		{
			NewCamLoc = CamAngle2;
			SharedCameraID = CamID2;
		}
	}
	if ( bCheckCamVector3 == true )
	{
		if ( bCheckPlayer_X_Pos_3 && (LocalPlayer.Location.X >= MoveCamVector3.X) )
		{
			NewCamLoc = CamAngle3;
			SharedCameraID = CamID3;
		}
		if ( bCheckPlayer_X_Neg_3 && (LocalPlayer.Location.X <= MoveCamVector3.X) )
		{
			NewCamLoc = CamAngle3;
			SharedCameraID = CamID3;
		}
		if ( bCheckPlayer_Y_Pos_3 && (LocalPlayer.Location.Y >= MoveCamVector3.Y) )
		{
			NewCamLoc = CamAngle3;
			SharedCameraID = CamID3;
		}
		if ( bCheckPlayer_Y_Neg_3 && (LocalPlayer.Location.Y <= MoveCamVector3.Y) )
		{
			NewCamLoc = CamAngle3;
			SharedCameraID = CamID3;
		}
		if ( bCheckPlayer_Z_Pos_3 && (LocalPlayer.Location.Z >= MoveCamVector3.Z) )
		{
			NewCamLoc = CamAngle3;
			SharedCameraID = CamID3;
		}
		if ( bCheckPlayer_Z_Neg_3 && (LocalPlayer.Location.Z <= MoveCamVector3.Z) )
		{
			NewCamLoc = CamAngle3;
			SharedCameraID = CamID3;
		}
	}
	if ( bCheckCamVector4 == true )
	{
		if ( bCheckPlayer_X_Pos_4 && (LocalPlayer.Location.X >= MoveCamVector4.X) )
		{
			NewCamLoc = CamAngle4;
			SharedCameraID = CamID4;
		}
		if ( bCheckPlayer_X_Neg_4 && (LocalPlayer.Location.X <= MoveCamVector4.X) )
		{
			NewCamLoc = CamAngle4;
			SharedCameraID = CamID4;
		}
		if ( bCheckPlayer_Y_Pos_4 && (LocalPlayer.Location.Y >= MoveCamVector4.Y) )
		{
			NewCamLoc = CamAngle4;
			SharedCameraID = CamID4;
		}
		if ( bCheckPlayer_Y_Neg_4 && (LocalPlayer.Location.Y <= MoveCamVector4.Y) )
		{
			NewCamLoc = CamAngle4;
			SharedCameraID = CamID4;
		}
		if ( bCheckPlayer_Z_Pos_4 && (LocalPlayer.Location.Z >= MoveCamVector4.Z) )
		{
			NewCamLoc = CamAngle4;
			SharedCameraID = CamID4;
		}
		if ( bCheckPlayer_Z_Neg_4 && (LocalPlayer.Location.Z <= MoveCamVector4.Z) )
		{
			NewCamLoc = CamAngle4;
			SharedCameraID = CamID4;
		}
	}
}

//=============================================================================
// Camera Adjustment
//=============================================================================
function SetCameraMode()
{
	if ( ActiveCamera == none )
		return;
	//============================================================================================
	if ( bCheckCamVector1 )
	{
		switch Vect1CamMode
		{
			case CM_None:
				break;
			case CM_Track1:
				NewCameraMode = CM_Track1;
				break;
			case CM_Track2:
				NewCameraMode = CM_Track2;
				break;
			case CM_CustomCamDistance1:
				NewCameraMode = CM_CustomCamDistance1;
				break;
			case CM_CustomCamDistance2:
				NewCameraMode = CM_CustomCamDistance2;
				break;
			default:
				break;
		}
	}
	//======================
	if ( bCheckCamVector2 )
	{
		switch Vect2CamMode
		{
			case CM_None:
				break;
			case CM_Track1:
				NewCameraMode = CM_Track1;
				break;
			case CM_Track2:
				NewCameraMode = CM_Track2;
				break;
			case CM_CustomCamDistance1:
				NewCameraMode = CM_CustomCamDistance1;
				break;
			case CM_CustomCamDistance2:
				NewCameraMode = CM_CustomCamDistance2;
				break;
			default:
				break;
		}
	}
	//======================
	if ( bCheckCamVector3 )
	{
		switch Vect3CamMode
		{
			case CM_None:
				break;
			case CM_Track1:
				NewCameraMode = CM_Track1;
				break;
			case CM_Track2:
				NewCameraMode = CM_Track2;
				break;
			case CM_CustomCamDistance1:
				NewCameraMode = CM_CustomCamDistance1;
				break;
			case CM_CustomCamDistance2:
				NewCameraMode = CM_CustomCamDistance2;
				break;
			default:
				break;
		}
	}
	//======================
	if ( bCheckCamVector4 )
	{
		switch Vect4CamMode
		{
			case CM_None:
				break;
			case CM_Track1:
				NewCameraMode = CM_Track1;
				break;
			case CM_Track2:
				NewCameraMode = CM_Track2;
				break;
			case CM_CustomCamDistance1:
				NewCameraMode = CM_CustomCamDistance1;
				break;
			case CM_CustomCamDistance2:
				NewCameraMode = CM_CustomCamDistance2;
				break;
			default:
				break;
		}
	}
	//======================
	switch NewCameraMode
	{
		case CM_Track1:
			ActiveCamera.CamCueue = CM_Track1;
			break;
		case CM_Track2:
			ActiveCamera.CamCueue = CM_Track2;
			break;
		case CM_CustomCamDistance1:
			ActiveCamera.CamCueue = CM_CustomCamDistance1;
			break;
		case CM_CustomCamDistance2:
			ActiveCamera.CamCueue = CM_CustomCamDistance2;
			break;
		case CM_MoveTransition:
			ActiveCamera.CamCueue = CM_MoveTransition;
		default:
			break;
	}
	//============================================================================================
	if ( SharedCameraID != LocalPlayer.CurCamID )
	{
		ActiveCamera.TargetDistance = TrackCustomDistance; //Linear distance interpolation
		ActiveCamera.DesiredRotation = NewRotation; //Linear rotation interpolation (layer 1) towards this orientation
		ActiveCamera.bCamXAxisLock = bCamXAxisLock;
		ActiveCamera.bCamYAxisLock = bCamYAxisLock; 
		ActiveCamera.bCamZAxisLock = bCamZAxisLock;
		ActiveCamera.bRestorePitch = bRestorePitch;
		ActiveCamera.bRestoreYaw = bRestoreYaw;
		ActiveCamera.bRestoreRoll = bRestoreRoll;
			
		if ( bInstantLocTransition )
		{
			if ( ActiveCamera.CameraMode == CM_MoveTransition )
				ActiveCamera.CamCueueAdjust();
			ActiveCamera.SetLocation( NewCamLoc);
			ActiveCamera.SetRotation( ActiveCamera.DesiredRotation);
			ActiveCamera.ViewRotation = ActiveCamera.DesiredRotation;
			ActiveCamera.CamDistance = TrackCustomDistance;
			ActiveCamera.CamCueueAdjust();
			ActiveCamera.Tick(0.0); //Force immediate camera update
		}
		if ( !bInstantLocTransition )
		{
			if ( ActiveCamera.CameraMode != CM_MoveTransition )
				ActiveCamera.CameraMode = CM_MoveTransition;
			if ( ActiveCamera.bTransitionMoving == false )
			{
				ActiveCamera.NewLoc = NewCamLoc;
				ActiveCamera.SetRotation( ActiveCamera.DesiredRotation);
				ActiveCamera.ViewRotation = ActiveCamera.DesiredRotation;
				ActiveCamera.CamDistance = TrackCustomDistance;
			}
		}
		LocalPlayer.OldCamID = LocalPlayer.CurCamID;
		LocalPlayer.CurCamID = SharedCameraID;
	}
}

function bool HasActiveCamera()
{
    if ( ActiveCamera != none )
        return true;
    //No camera, find it
    ForEach AllActors (class'RPG_Camera', ActiveCamera)
        return true;
}

defaultproperties
{
	bHidden=true
	bEdShouldSnap=True
	DrawType=DT_Sprite
	Texture=Texture'Engine.S_SpecialEvent'
	Style=STY_Masked
}
<<| http://uncodex.ut-files.com/ |>>

Code reference for UGold, UT99, Unreal2, UT2k3, UT3
Additional Beyond Unreal Wiki Links
Show
wiki.beyondunreal.com/Legacy:Console_Bar
wiki.beyondunreal.com/Exec_commands#Load
wiki.beyondunreal.com/Legacy:Exec_Directive#Loading_Other_Packages
wiki.beyondunreal.com/Legacy:Config_Vars_And_.Ini_Files
wiki.beyondunreal.com/Legacy:INT_File

User avatar
sektor2111
Godlike
Posts: 4167
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Camera Not Transitioning Properly

Post by sektor2111 » Sun Sep 11, 2016 7:00 am

I don't know if things must be complex or simple.
On such game-type, Levels should be done using paths or other sort of "references" else finding a good position of view without testing a visible actor as a location + a few UU on Z axis, will need more work. Level might be complex (or bugged well), so you might want a "Trace" check cycling. If they don't have a trace find a nearest traceable "reference" to gain visibility. As you might figure, empty Levels are not for Games, they need paths, keypoints, or other sort of helpful things rather than walls only, or your pawn having "Traceshot" in a random direction (or less random) probably has chances to find a camera-spot.

User avatar
LannFyre
Skilled
Posts: 233
Joined: Sun Dec 28, 2014 1:10 am
Location: Anubitek

Re: Camera Not Transitioning Properly

Post by LannFyre » Sun Sep 11, 2016 7:52 am

While your response does confirm a few things I thought about (making specific nodes for the camera to find instead of triggers that hold coordinates), I don't think you gave an answer regarding the ceasing of movement. That being said, I like the trace check idea, can you think of any examples I should look at for trace checks?
<<| http://uncodex.ut-files.com/ |>>

Code reference for UGold, UT99, Unreal2, UT2k3, UT3
Additional Beyond Unreal Wiki Links
Show
wiki.beyondunreal.com/Legacy:Console_Bar
wiki.beyondunreal.com/Exec_commands#Load
wiki.beyondunreal.com/Legacy:Exec_Directive#Loading_Other_Packages
wiki.beyondunreal.com/Legacy:Config_Vars_And_.Ini_Files
wiki.beyondunreal.com/Legacy:INT_File

User avatar
sektor2111
Godlike
Posts: 4167
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Camera Not Transitioning Properly

Post by sektor2111 » Sun Sep 11, 2016 5:11 pm

I think movement has to happen fast - some supposed enemy will attack and you have to see how to defend or fight - maybe like a projectile or such not really instantly but faster enough.
Then detecting nearby possible camera points:
- permanent player is hunting a position VIA an Actor Owned;
- permanent camera is hunting a position using such an Actor Tracker because camera is busy with job on purpose;
Such a tracker will examine if Tracing Player-Camera went screwed or distance is too big. If yes or out of sight move (projectile physics ?) to new chosen point and turning.
Options for tracking might be a Radius check iteration around max 1500 UU in whatever state code or a normal iterator using TAG for speed, so to speak this actor reference will have an unique tag.

User avatar
sektor2111
Godlike
Posts: 4167
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Camera Not Transitioning Properly

Post by sektor2111 » Sat Oct 08, 2016 8:00 am

You have to think at Bot for a few moments and some code
if (!LineOfSightTo(MyOwner) || (Vsize(Location-MyOwner.Location ) > 780 )
FindADirectSight()

FindDirectSight()
Foreach radious actors Navigationpoint in 500 UU range and
Trace NO HitActor between Camera and MyOwner - see MH504 for tracing (it's about door problems)

if match a view rotate to Owner (small state steps using sleep)
If Reachable NavPoint.Location tracked && Location != (navPoint.Location + vect (0,0,80)
MoveTarget.Location or Destination = Nav.Location + vect (0,0,80) (if position is available using a test deco moved there first)
Else MoveTo=FindPathTo(Node.Location)

I'm not sure if this pawn specific stuff already available has to be rewritten more complex causing bugs and headaches.
Might test and take in account Airspeed WaterSpeed for movement probably camera doesn't run or walk it might fly and swim.

I asure you that flier pawn is good at using paths much "enhanced" than a Bot - I have tested this.

Else your lack of default knowledge gives you headaches in creating stuff which is already available without much X,Y,Z pain.

Then if you need some insane paths I'll teach you some pathing "hints" and camera won't fail.

Simple stuff will force future mapper (if game is successfull) to do maps properly not as they did with MH. Simply if camera doesn't work nobody will load crap so efficiency is a prevention for future quality, forget those maths because complexity of a map heads in failures at a moment and use SIMPLE stuff first. If simplicity fails, then get into complex route.

To summarize you need a function as follows:
- LineOfSight - native;
- ActorReachable (Or PointReachable) - native;
- Trace - written inspired from CanFireAtEnemy();
- MoveTo() - native;
- TurnTo or Rotator - native;
- VSize() - native;
As you can see there are options useable without reinventing wheel.
For more simplicity of problem see Fly or Manta Code at roaming or somewhere in combat - they can find enemy, no worries.

Post Reply