- Home /
object moves out of the screen
i m using the Input.acceleration code 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; // Z is the axis which controls left and right.
// 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);
the problem i m having is the object(sphere) moves out of the screen...and the object doesn't move left wen phone is tilted left nor right....please do help???
it's not clear man, view the tutorial in the left side, and make a code clear
i made the object movement according to the tilt using function update(){ var dir : Vector3 = Vector3.zero; dir.x = -Input.acceleration.x;
dir *= Time.deltaTime;
transform.Translate (-dir * speed);
}
but now the object(sphere),wen tilted to the left ,moves to the left n out of the screen...and similar to the right...please help about how to get it going?
for simple technique set a collider at the edge of the screen, or u want in code
Your answer
Follow this Question
Related Questions
Player movement on tilting platform 0 Answers
Orbiting objects appear stretched 1 Answer
How to move an object a fixed distance along one of its axis 1 Answer
Unity limiting max velocity on Rigidbody? 5 Answers
Move parent with child 1 Answer