Im trying to make a player move 360 degree gyroscopic movement on my phone
Im trying to make a player move 360 degree gyroscopic movement on my phone
My player (parent) has a camera attached and whatever direction I look that's where it goes. but the Player goes off at it's own speed (much slower than the camera) and just walks forward.
But when i disabled player move script on the camera, the character just moved forwards and backwards no matter which direction the phone is pointing.
[see attached video] https://youtu.be/pjU4MsV_Qfw
here is the code
private bool gyroEnabled;
private Gyroscope gyro;
//private GameObject cameraContainer;
private Quaternion rot;
private void Start()
{
//cameraContainer = new GameObject ("Camera Container");
//cameraContainer.transform.position = transform.position;
//transform.SetParent (cameraContainer.transform);
gyroEnabled = EnableGyro();
}
private bool EnableGyro()
{
if (SystemInfo.supportsGyroscope)
{
gyro = Input.gyro;
gyro.enabled = true;
//cameraContainer.transform.rotation = Quaternion.Euler (90f, 90f, 0f);
rot = new Quaternion (0, 0, 1, 0);
return true;
}
return false;
}
private void Update()
{
if (gyroEnabled)
{
transform.localRotation = gyro.attitude * rot;
}
}
here is the Player (parent) and camera (child)
Any suggestions?
Your answer
Follow this Question
Related Questions
Moving.Rotating a Raycast with Respect to Rotation 1 Answer
Make character move up on Y axis as apposed to move forward in Z space when mobile device is tilted 2 Answers
How do I adjust code so gyro translates player to center position when device is being held in hands 1 Answer
the player input is jittery seems like glitching 0 Answers
How to make a 2D rigidbody vertically when input is via the gyroscope 0 Answers