Pages

četvrtak, 9. svibnja 2013.

Making Simple Android Game ( Sensor Moving )

// Move object using accelerometer
var speed = 10.0;

function Update () {
    var dir : Vector3 = Vector3.zero;

    // we assume that device is held parallel to the ground
    // and Home button is in the right hand
   
    // remap device acceleration axis to game coordinates:
    //  1) XY plane of the device is mapped onto XZ plane
    //  2) rotated 90 degrees around Y axis
    dir.x = -Input.acceleration.y;
    dir.z = Input.acceleration.x;
   
    // clamp acceleration vector to unit sphere
    if (dir.sqrMagnitude > 1)
        dir.Normalize();
   
    // Make it move 10 meters per second instead of 10 meters per frame...
    dir *= Time.deltaTime;
       
    // Move object
    transform.Translate (dir * speed);
}



Video Tutorial How to use it :


 http://www.youtube.com/watch?v=FjXAcMAE_C4&feature=youtu.be





1 komentari:

  1. Hey my friends I tell you some tips about Be very careful with the timing of your nitrous. Generally speaking, it's a little wasted while you're shifting up the first couple of gears. We found the best time to activate it is after you've shifted up twice at the earliest. Make sure that you're not about to hit a drift section though, otherwise you'll waste this very useful boost.
    RPG Finder

    OdgovoriIzbriši