# Gravity Vector is Fooled

**URL:** <https://forums.unrealengine.com/t/gravity-vector-is-fooled/353740>\
**Category:** XR Development\
**Tags:** roll, unreal-engine, Android, question, CPP\
**Created:** [April 11, 2016, 9:21am UTC](https://forums.unrealengine.com/t/gravity-vector-is-fooled/353740 "2016-04-11T09:21:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ErayT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ErayT](https://forums.unrealengine.com/u/ErayT)\
**Post date:** [April 11, 2016, 9:21am UTC](https://forums.unrealengine.com/t/gravity-vector-is-fooled/353740/1 "2016-04-11T09:21:55Z")

</div>

Hi people,

I am currently trying to implement a basic VR head motion in my project. The problem is that I am not comfortable with the sensor values provided. For instance, I roll my camera with respect to gravity but the gravity vector is affected by the other forces as well(when I turn around myself for instance) and this causes my camera to roll even if I do not roll the phone. I could not find a way to remove those other forces effecting gravity vector. Any idea?

```
void APlayerVR::PerformRoll(FVector Gravity)
{
	FRotator CameraRotation = CameraComponent->GetComponentRotation();
	float CurrentRoll = CameraRotation.Roll;
	float TargetRoll = Gravity.Y * 10.0f;

	CameraRotation.Roll = FMath::Lerp(CurrentRoll, TargetRoll, 0.1f);
	CameraComponent->SetWorldRotation(CameraRotation);
}
```
