|
This is
fairly simple coding wise but a little more subtle than most things to
understand, but once you do, it like opens up a whole new world of
possbilities. Any viewing angle is possible, and all look incredible
running in Unreal.
* First thing you need is a player model to use
for your perspective I chose MaleTwo for no apparent reason, not even sure
what it looks like, but you get the picture. Create a new class under one
of the Unreal player model classes, and call it whatever you like...then
the fun starts.
* Basically the only function you need to modify
is the event Player CalcView which calculates the camera position and
rotation, when this function ends another function actually does all the
dirty work, but you don't need to worry about it.
* You don't
actually need most of the code in PlayerCalcView, in fact you just need to
alter the CameraLocation and CameraRotation.
* Once you have
placed the camera where you want it, facing where you want it, you
basically have a whole new game.
class SideView expands MaleTwo;
event
PlayerCalcView( out actor ViewActor, out vector CameraLocation, out
rotator CameraRotation ) { // Just need to
set bBehindView to true, otherwise the 1st
person // perspective model is used (i.e. just
the gun, no player, not // something we want
here :P). Also set ViewActor to yourself, cuz
// that's what you're looking at.
ViewActor = Self; bBehindView =
true; // The Camera's
location is a vector that is placed at the
player // when this function is called.
Because we want to implement a // side view
camera, we will have to shift it to the right by
a // certain amount. The Y component of a
actor's location is its // side to side
offset, while X is front to back and Z is up
and // down. So lets move the Camera over to
the side of the player // by a certain amount
plus the size of the Player Model. I'll //
choose 350 for this, but really you can mess around with it
to // get the desired
view.
CameraLocation.Y += CollisionRadius
+ 350; // Great, so now
we have our camera positioned to the side of
the // player, but unfortunatly, up to this
point, it will be facing // whichever
direction the player is facing, or his
ViewRotation. // To avoid this, we should set
the camera's rotation to something // fixed,
because we don't want the camera to tilt for
this // tutorial, ofcourse this is totally
arbitrary and you can modify // it however you
want. Rotation consists of 3 quantities,
Pitch, // Yaw, and Roll. Without going too
much into it, Pitch is the // up-down tilting,
yaw is the left-right tilting and Roll is //
basically just that how much the thing is rolling. For
our // purposes, we just want the camera to
tilt to the side a bit // and look at our
model from the side, so lets create a new //
rotator that will not have any change in up/down tilting,
or // roll, but will tilt/look to the side by
-50 to essentially // look at the
player.
CameraRotation =
rotator(vect(0,-50,0)); }
| Now
you have a great new camera view coded, but how do you go about seeing it
in a level?? Well, there are two options, the easiest, for yourself
anyways is to do it using Unreal.ini. Just open up the file, and at around
the 25th line or so under the section [URL] will be a line called
Class="blah" where "blah" is the name of your default player type, just
change this to be Class = YourPackageName.YourClassName, and your all set.
You can now use this perspective in any map you wish that does not change
the default player value, which is most. The other alternative is to
create your own gameinfo class that will have your player as a default.
This is more beneficial if you want to create a new hud, or want to get
rid of the CrossHair. Look at my Hud tutorial for info on creating a new
gameinfo class.
|