Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Accelerometer sensitivity settings for the iPhone? Help Please

Discussion in '2D' started by malachiddm, Mar 3, 2015.

  1. malachiddm

    malachiddm

    Joined:
    Dec 30, 2014
    Posts:
    44
    Pretty straight forward to the point, I created a game on Google Play using this exact code. The Accelerometer is much more sensitive making the game difficult.
    Just today I made the iOS version and it's not very sensitive at all. So I'm trying to boost the sensitivity a little more then what it is now for the IPhone build. How would I go about doing this?? Here is my code.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Basket : MonoBehaviour {
    5.    
    6.     public Camera cam;
    7.    
    8.  
    9.     private bool canControl;
    10.    
    11.     // Use this for initialization
    12.     void Start () {
    13.         if (cam == null) {
    14.             cam = Camera.main;
    15.         }
    16.         canControl = false;
    17.  
    18.  
    19.     }
    20.    
    21.     // Update is called once per frame
    22.     void Update () {
    23.         Vector3 pos = transform.position;
    24.         pos.z = 0;
    25.         transform.position = pos;
    26.         if (canControl) {
    27.             transform.Translate (Input.acceleration.x, 0, -Input.acceleration.z);
    28.             rigidbody2D.position = new Vector2(
    29.                 Mathf.Clamp (rigidbody2D.position.x, -2.7f, 2.7f), 0.0f);
    30.         }
    31.     }
    32.     public void ToggleControl (bool toggle) {
    33.         canControl = toggle;
    34.     }
    35. }
    36.  
     
  2. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    897
    Can't you just multiply the Input.acceleration with a scale factor? Something like:
    Code (CSharp):
    1. float scale = 10f;
    2. Vector3 scaled = Input.acceleration.x * scale;
    3. transform.Translate (scaled.x, 0, -scaled.z);
    4.  
     
  3. malachiddm

    malachiddm

    Joined:
    Dec 30, 2014
    Posts:
    44
    It's not working. I get a error saying cannot implicitly convert type 'float to unity engine.vector3

     
  4. PerfectlyInsane

    PerfectlyInsane

    Joined:
    Aug 9, 2013
    Posts:
    74
    Vector3 must always be (x,y,z) format

    For example

    Vector3 getPositionTarget = transform.position- new Vector3(0.01f,0.01f,0.01f);
     
    Last edited: Mar 4, 2015
  5. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    897
    Ooops, my bad, it should of course be:
    Code (CSharp):
    1. float scale = 10f;
    2. Vector3 scaled = Input.acceleration * scale;
    3. transform.Translate (scaled.x, 0, -scaled.z);