I have an orthographic camera
set on position(0,0,-10)
, rotation(0,0,0)
and it's parent - CameraHolder
with a transform
:
which gives an isometric feel:
Now, I need to move the ball with the accelerometer so here's how the FixedUpdate()
looks like:
void FixedUpdate ()
{
if (SystemInfo.deviceType == DeviceType.Desktop)
{
// Player movement in desktop devices
// Definition of force vector X and Y components
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
// Building of force vector
Vector3 movement = new Vector3 (moveHorizontal,0.0f,moveVertical);
// Adding force to rigidbody
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
else
{
// Player movement in mobile devices
// Building of force vector
Vector3 movement = new Vector3 (Input.acceleration.x, 0.0f, Input.acceleration.y);
// Adding force to rigidbody
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
}
I need to translate the movement by 45 degrees, but I have no idea how.
If anyone has a clue, I'd be grateful for help!