Monday, August 15, 2016

Unity Project... Day 3?

I forgot to post a second update.

About a month ago, I tested exporting the APK and using the phone's accelerometer to drive the ball.

After some updating and dealing with some settings issues from moving to Unity 5, I exported a working APK. However, the ball didn't initially move with my existing code.




Some of this code was already there, such as the variable names. The primary things that needed to be added to use the accelerometer were enabling it in the Start() function, and

    private Rigidbody m_ballRigidBody; //This is our player
    private Vector3 m_gyroMovement; //This will be the vector to move him.

  void Start()
{
        Input.gyro.enabled = true; //This lets us access the accelerometer
        m_ballRigidBody = GetComponent();        }

private void FixedUpdate()
{
                  //These transfer the accelerometer's force to movement in the x and z axes.
        m_gyroMovement.x = Input.acceleration.x;
        m_gyroMovement.z = Input.acceleration.y;
        m_ballRigidBody.AddForce(m_gyroMovement * speed); //And this adds that force to our player.
        }



Today, I did some texture painting.






The walls look strangely tall in this camera view. You can see how much flatter they are when I rotate it at the end.