abhishek.arts
11-16-2009, 11:50 AM
Hey guys!
I just got UDK, and despite being a complete beginner in coding C++ let alone UnrealScript, i decided on following a variety of source codes and tutorials out there. I managed to make my camera hover above and follow my pawn - controlled by WASD etc. etc.
I've been trying for a while, but I can't seem to do the following:
1) free the camera from the character. ie: WASD affects the camera, but not the actual character
2) left key / right key adjust the rotation of the camera, keeping the focus at the centre of the screen
3) have camera zoom in and become closer to a person's viewpoint, or zoom out and become more like a god's viewpoint on mouse scrollling.
There was other stuff I was attempting to do, but I still want to give them a few more shots before asking for help about them.
Thanks in advance guys.
Cheers
Chris2009
11-16-2009, 12:02 PM
If your new to coding and new to unrealscript I would suggest starting with something not so hard to achieve.
Maybe a few Mutators on weapons etc and then go from there.
I don't think anyone will explain how to do the things you are asking.
sorry i couldn't be more help
pajari
11-27-2009, 05:27 PM
I've been working on the same thing. I haven't figured it out yet but I've got some ideas, maybe we can use this thread to bounce ideas off one another and get this done finally.
All the cameras I've seen have a few important functions that any RTS camera is going to have to make use of- the biggest one is UpdateCamera(). In GameFixedCamera, the method looks like this.
simulated function UpdateCamera(Pawn P, float DeltaTime, out TViewTarget OutVT)
{
local CameraActor CamActor;
// are we looking at a camera actor?
CamActor = CameraActor(OutVT.Target);
if (CamActor != None)
{
// we're attached to a camactor, use it's FOV
OutVT.POV.FOV = CamActor.FOVAngle;
}
else
{
OutVT.POV.FOV = DefaultFOV;
}
// copy loc/rot from actor we're attached to
if (OutVT.Target != None)
{
OutVT.POV.Location = CamActor.Location;
OutVT.POV.Rotation = CamActor.Rotation;
}
// cameraanims, etc
PlayerCamera.ApplyCameraModifiers(DeltaTime, OutVT.POV);
// if we had to reset camera interpolation, then turn off flag once it's been processed.
bResetCameraInterpolation = FALSE;
}
OutVT is the key here, I think. It's a struct in the Camera class that has a bunch of attributes. It has an Actor, a TPOV (another struct containing rotation, FOV and position data, very important), the aspect ratio, etc. The problem with OutVT is that it relies on an Actor to provide it with its viewpoint. So we have to either make an Actor-derived class that isn't a pawn or anything but does have a presence in a level and can provide us with a TPOV, or we need to extend Camera itself and make an entirely new OutVT struct.
Here's the same method from GameThirdPersonCamera:
function UpdateCamera(Pawn P, float DeltaTime, out TViewTarget OutVT)
{
if( P == None && OutVT.Target != None )
{
OutVT.Target.GetActorEyesViewPoint( OutVT.POV.Location, OutVT.POV.Rotation );
}
// give pawn chance to hijack the camera and do it's own thing.
else if( (P != None) && P.CalcCamera(DeltaTime, OutVT.POV.Location, OutVT.POV.Rotation, OutVT.POV.FOV) )
{
//@fixme, move this call up into GearPlayerCamera??? look into it.
PlayerCamera.ApplyCameraModifiers(DeltaTime, OutVT.POV);
return;
}
else
{
UpdateCameraMode(P);
if( CurrentCamMode != None )
{
PlayerUpdateCamera(P, DeltaTime, OutVT);
CurrentCamMode.UpdatePostProcess(OutVT, DeltaTime);
}
else
{
`warn(GetFuncName() @ "CameraMode == None!!!");
}
// prints local space camera offset (from pawnloc). useful for determining camera anim test offsets
//`log("***"@((OutVT.POV.Location - P.Location) << P.Controller.Rotation));
}
// if we had to reset camera interpolation, then turn off flag once it's been processed.
bResetCameraInterpolation = FALSE;
}
This is a lot less helpful, I think, because it actually makes use of that Pawn P argument. At least GameFixedCamera's method only requires an Actor (by way of OutVT) which is something I think it will be easier to code around.
Anyway, those are my thoughts. Right now I'm trying to extend GameFixedCamera, give it a set Rotation and FOV, and figure out how to divorce it from player-owned Pawns. I do not know if this is the correct way to go about this. Hopefully someone else with a different bit of knowledge can come in here and share.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.