Quantcast
Channel: Questions in topic: "device"
Viewing all articles
Browse latest Browse all 270

How to set mobile device position zero

$
0
0
Hi guys, Im just starting my adventure with c# and unity so please forgive me my lack of knowledge and messy code. I was digging through the internet for 2 days , but nothing i found worked for me. What I need is how to get device position on void start, so every time i run game, game detects phone in 0 position.` ---------- public class Controller : MonoBehaviour { Rigidbody rb; float dirX; public float moveSpeed = 10f; // Start void Start () { rb = GetComponent (); } // Update void Update () { dirX = Input.acceleration.x * moveSpeed; //limit y-axis movement for future ramps etc transform.position = new Vector3(transform.position.x, Mathf.Clamp (transform.position.y,-99f,20f), transform.position.z); } // FixedUpdate void FixedUpdate() { rb.velocity = new Vector3 (0, -4f, dirX); transform.position = new Vector3(transform.position.x - 0.2f, transform.position.y, transform.position.z); } } ---------- I have tried This one **[how to detect device start position for player acceleration (iPhone)][1]** But it didn't work for me neither(im working on android). I will appreciate any advice and help. [1]: https://answers.unity.com/questions/1619339/accelerometer-start-position-for-iphone.html

Viewing all articles
Browse latest Browse all 270

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>