- Home /
Changing Global to Local Movement
I need to make this script so that when my character falls on his side, movement is normal. This is my script but when you fall on your side and tot the device, you move up and down. It's a 2D game if that maters.
using UnityEngine;
using System.Collections;
public class AccelerometerInput : MonoBehaviour
{
void Update ()
{
transform.Translate(Input.acceleration.x, 0, 0);
}
}
What do you mean by normal? transform.Translate translates the object in local space by default. You want to translate it in global space to maintain movement in a horizontal direction?
Translate in world space like this
transform.Translate(Input.acceleration.x, 0, 0, Space.World);
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Force iOS first person to move slightly when player is not moving it? 1 Answer
Android/iOS: How to launch an application from inside another application 0 Answers
Jet Accelerometer Script 1 Answer
Multiple Tiled GPU warning: RenderTexture color surface errors? 0 Answers