- Home /
Accelerometer Movement Problem
I'm working on a game that's kind of a spin off of tetris where you control the falling objects by tilting your device, but the problem I'm having is when someone tilts the device too much it starts getting stuck on the side instead of falling. Is there a way for me to override the movement when the user hits my side boundaries so the piece will continue to fall instead of get stuck on the side until the user tilts in the opposite direction?
Answer by Justin Warner · Apr 26, 2011 at 02:59 AM
Sense the piece is changing it's position every frame (I assume), then you could check the last XYZ (Whichever it is meaning it's not falling down), and check to see if it's in the same position, if it's in the same position, "manually" move it _ distance away, if it's moving enough, then leave it alone... Also, you can even have it so that it "snaps" to a "grid." Mind you, you'd have to code so said grid, but it's also a route you can take.
Hope this helps a little, good luck!
Answer by Yuemari · Apr 01, 2012 at 10:00 PM
I used to have a similar problem and the way i solve it was: In LateUpdate -save my position to a temp vector -move my object in the desired position -check if(position.(XYZ) < minlimit.(XYZ) || position.(XYZ) > maxLimit.(XYZ) ) -if this is true then im offlimits so i need to correct my position to the temp value stored previously -then object position = temp;
You need to have a minLimit and a maxLimit for this to work. Good Luck!
Your answer
Follow this Question
Related Questions
Gyroscope based First person controller 0 Answers
Controlling Unity3D PC Application from IPAD/IPHONE 1 Answer
Move a Game Object (Camera) forward and sideways with the Mobile Sensor Outputs. How? 0 Answers
MIDI on iOS devices 3 Answers
What do i need to run my built application for iphone using unity to be run on android devices 1 Answer