Quantcast
Channel: Latest Questions by Natasa
Viewing all articles
Browse latest Browse all 6

Camera rotation in maze game depending of accelerometer

$
0
0
I'm still newbie... I'm trying to develop simple maze game. I want to roll my ball through maze, but I have to rotate camera left or right, otherwise the player can't see what's behind while rolling the ball on the left or on the right. void Start () { offset = transform.position - player.transform.position; } void LateUpdate() { transform.position = player.transform.position + offset; } I'm using low pass filter for accelerometer values: Vector3 lowpass() { float LowPassFilterFactor = AccelerometerUpdateInterval / LowPassKernelWidthInSeconds; lowPassValue = Vector3.Lerp(lowPassValue, Input.acceleration, LowPassFilterFactor); return lowPassValue; } Accelerometer values are from -1 to 1 for each coordinate. Because of that I check my lowPassValue.x value and limit it. If it's positive ( >0.3 ), then the camera should turn right and if it's negative (

Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images