C++ Camera

I think that Epic continues to do an amazing job with its tutorial content for Unreal 4. The C++ tutorials are as good as any I’ve used and offer some really interesting tasks to sink your teeth into.

This tutorial builds an interesting camera systems which allows players to rotate around and zoom into a static mesh. It’s very much a third person game camera, but just using it evokes the feeling of an adventure or detective game, where the player is moving through an environment, searching for clues, and zooming in on areas of interest.

c-logo

The original code creates a camera with a very pedestrian speed, designed for moving slowly through the level:

I wanted to experiment with this and get the camera moving faster through the world. As the camera was attached to the root component (which is centred at the same location as the static mesh) the best way to speed up the movement of the camera was to speed up the movement of the root component. I made the following changes:

if (! MovementInput.IsZero ())

{

MovementInput = MovementInput. SafeNormal() * 100.0f ;

FVector NewLocation = GetActorLocation();

NewLocation += GetActorForwardVector() * MovementInput .X * DeltaTime ;

NewLocation += GetActorRightVector() * MovementInput.Y * DeltaTime ;

SetActorLocation(NewLocation );

}

 

if (! MovementInput.IsZero ())

{

MovementInput = MovementInput. SafeNormal() * 333.0f ;

FVector NewLocation = GetActorLocation();

NewLocation += GetActorForwardVector() * MovementInput .X * DeltaTime ;

NewLocation += GetActorRightVector() * MovementInput.Y * DeltaTime ;

SetActorLocation(NewLocation );

}

This resulted in the following effect:

The camera now can move much quicker through the world. This makes it seem much more like an action game camera, rather than an adventure game camera. Again, it’s cool watching these seemingly minor tweaks having significant effects on the feel of this prototype. That being said, these tweaks are no more immediate and easy than using editable variables when in-engine. The thing I took away from this tutorial is that, when it comes to code, the more you look at it the more understandable it is. That being said, from a prototyping point of view, if the variables are available to you, working exclusively in-engine is probably quicker for the way I work.

There is one more tutorial to complete which, with some thoughts and analysis, will be my next and final post in this series.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s