# Trying to code the Camera location/position in code

**URL:** <https://forums.unrealengine.com/t/trying-to-code-the-camera-location-position-in-code/305298>\
**Category:** C++\
**Tags:** unreal-engine, CPP, question\
**Created:** [January 28, 2015, 11:05pm UTC](https://forums.unrealengine.com/t/trying-to-code-the-camera-location-position-in-code/305298 "2015-01-28T23:05:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe\_Storm\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Joe\_Storm\_1](https://forums.unrealengine.com/u/Joe_Storm_1)\
**Post date:** [January 28, 2015, 11:05pm UTC](https://forums.unrealengine.com/t/trying-to-code-the-camera-location-position-in-code/305298/1 "2015-01-28T23:05:41Z")

</div>

Hey, I’m new to programming in UE4 and I’m having trouble with how to code the Camera position using C++. I tried two different ways, but it seems not to be doing the trick. My intentions is to move the camera with the PlayerController class; But, I want to set a default location for the camera when the game has started. Everything I seem to do has failed. Here’s the header code for it.

CPCameraController.h

```
UCLASS()
class CAMERAPRACTICE_API ACPCameraController : public APlayerController
{
	GENERATED_UCLASS_BODY()

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
	TSubobjectPtr<UCameraComponent> FirstPersonCameraComponent;

	
	
};

```

and here’s the CPP of it

```
ACPCameraController::ACPCameraController(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	// Creating the camera component
	FirstPersonCameraComponent = PCIP.CreateDefaultSubobject<UCameraComponent>(this, TEXT("CPFirstCamera"));
	//FirstPersonCameraComponent->RelativeLocation = FVector(50, 0, 112);
	FirstPersonCameraComponent->AddLocalTransform(FTransform(FVector(0, 0, 112)));

	
}

```

I have yet write the code to move, but I wanted to see my problem on here first. I don’t know if the reason is because I have the camera in the PlayerController class.

---

<div class="post-metadata">

**Author:** ![JaredTherriault](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jaredtherriault/32/1194499_2.png) [@JaredTherriault](https://forums.unrealengine.com/u/JaredTherriault)\
**Post date:** [January 29, 2015, 2:35am UTC](https://forums.unrealengine.com/t/trying-to-code-the-camera-location-position-in-code/305298/2 "2015-01-29T02:35:01Z")

</div>

In which engine version are you programming? A lot of this stuff is deprecated.

---

<div class="post-metadata">

**Author:** ![Joe\_Storm\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Joe\_Storm\_1](https://forums.unrealengine.com/u/Joe_Storm_1)\
**Post date:** [January 29, 2015, 5:25am UTC](https://forums.unrealengine.com/t/trying-to-code-the-camera-location-position-in-code/305298/3 "2015-01-29T05:25:28Z")

</div>

I’m using 4.5.1 right now. For some reason, 4.6 won’t work on my laptop
