using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class monkeyscript : MonoBehaviour
{
private Rigidbody2D body;
[SerializeField]
private float movespeed = 20f;
private float drift_x;
void Awake()
{
body = GetComponent<Rigidbody2D>();
}
// code for moving player in x direction with the help of gyroscope.
void Update()
{
drift_x = Input.acceleration.x * movespeed;
body.velocity = new Vector2(drift_x, body.velocity.y);
}
}
And the portion where the i think the error is starts form line number 54 in my code. When I run my code I get zero console errors or any other type of errors. I have already tried to change the value of “movespeed” and it didn’t worked. My main aim is that player should move in x direction when the device is tilted accordingly. But the speed of player in x direction is too slow. So please help me to correct my code or if my code is completely wrong please suggest me something better. I have also attached rigid body component picture.