Sniper's Paradise!
Security Cameras
This is a rundown of a quick security camera that will find a target and then start to track it, but thats about it... :) It is a good basis for expanding with some more features, maybe give it a default rotation in its Idle state, or the ability to switch targets, etc etc. Also included here is a simple trigger for testing out the camera, all it does is set the ViewTarget when something touches it, and reset the ViewTarget when the something untouches it.
// ============================================= // scam.scamCamera // =============================================
class scamCamera expands StationaryPawn;
// VisRadius is the max area to search for possible targets var() float VisRadius;
// TargetClass is the type of target we want to track var() class<Actor> TargetClass;
// Target stores a reference to our target once we have one var Actor Target;
// The Tracking state checks to make sure our Target is still valid // and then uses DesiredRotation to keep in the camera facing them. // By setting DesiredRotation and RotationRate you can have the // engine automatically rotate to a new direction. state Tracking { function Timer() { if (Target == NONE) { GotoState('Idle'); return; }
DesiredRotation = rotator(Target.Location - Location); DesiredRotation.Roll = Rotation.Roll; }
Begin: SetTimer(0.5, true); SetPhysics(PHYS_Rotating); }
// The Idle state looks for valid targets using the RadiusActors // iterator. Iterators are very useful functions that will go // through a list of actor based on the criteria you supply. // RadiusActors is just one of the available ones, look in the // Actor class to see the rest of them. // Once we find a target, and it is in front of the camera it // will set the Target and go to the Tracking state. auto state Idle { function Timer() { local Actor a; local vector x, y, z;
GetAxes(Default.Rotation, x, y, z); foreach RadiusActors(TargetClass, a, VisRadius) if ( ((a.Location - Location) dot x) > 0) { Target = a; GotoState('Tracking'); }
if (DesiredRotation == Rotation) {
} }
Begin: Target = NONE; if (TargetClass == NONE) TargetClass = class'Engine.Actor';
SetTimer(0.5, true); }
defaultproperties { VisRadius=1024.0 TargetClass=class'Engine.Pawn' Mesh=LodMesh'UnrealShare.EightPick' CollisionRadius=28.000000 RotationRate=(Pitch=5000,Yaw=5000,Roll=5000) }
// ============================================= // scam.CameraTrigger // =============================================
class CameraTrigger expands Trigger;
// When a player touches the trigger it will set the player's // viewtarget to the Camera. If you look at the PlayerCalcView() // function in PlayerPawn you will see that it will set the // view to the location and direction of ViewTarget if it is // set, which is exactly what we need for the security camera. function Touch( actor Other ) { local scamCamera c;
if( IsRelevant( Other ) ) { foreach AllActors(class'scamCamera', c, Event) if ( c.IsA('scamCamera') && Other.IsA('PlayerPawn') ) PlayerPawn(Other).ViewTarget = c;
}
Super.Touch(Other); }
// When the player stops touching the trigger it will go // ahead and reset their ViewTarget back to NONE, which // will reset their view back to normal. function UnTouch(actor Other) { if ( Other.IsA('PlayerPawn') ) { if ( PlayerPawn(Other).ViewTarget.Event == Tag ) PlayerPawn(Other).ViewTarget = NONE; } }
defaultproperties {
}
All logos and trademarks are properties of their respective owners.
Unreal™ is a registered trademark of Epic Games Inc.
Privacy Policy
Website by Softly
Powered by RUSH