- Home /
Moving objects performance in PC and Editor
I'm moving objects in the screen with transform.Translate (they don't start at the same time, they're ordered). I check the transform.position.y and, if equals -2, I reposition the object to transform.position.y = 11. So the objects seems to be falling in a loop. At some point, I stop the loop and the objects stops in order. In editor, I see perfectly what I need. In the PC and Android build, sometimes some object stops first than the previous object in order. I think that can be something about the update function, may be in editor runs more often than in a build, could be that?
EDIT: Here's the Update function of each object. What Im tying to do is that when I hit STOP, the objects with order 3 or more stops if they are not in the zone limited by y = moveLimit and y = bottomPosition. If they're in that zone, move until go out of that zone and then stops. Objects with order 0,1 and 2 will move until its destination and then stop.
void Update ()
{
if(moving == true)
{
transform.Translate (0, Time.deltaTime * -speed,0);
if(stop == false)
{
if(transform.position.y <= bottomPosition) { transform.position = new Vector2(transform.position.x,topPosition); }
}
else
{
if(order >= 3)
{
if((transform.position.y > moveLimit) || (transform.position.y <= bottomPosition))
{
moving = false;
}
}
else
{
if(transform.position.y <= rowDestination)
{
newPosition = new Vector2(transform.position.x,rowDestination);
transform.position = newPosition;
moving = false;
}
}
}
}
}
You say "y = moveLimit and y = bottomPosition" and but you use "or" (||). Is this correct?
Your answer
Follow this Question
Related Questions
Choppy movment for even the most basic stuff 2 Answers
using coroutines for move objects - performance. 1 Answer
Move forward + allow to step sideways. 0 Answers
Multiple Colliders malfunctioning 0 Answers
I need a way to run code much more frequently than update. Ideally, every 3 milliseconds 2 Answers