Hi,
I am trying to periodically “move” a texture from outside of the screen towards its center. The texture I am currently using is 500 px (but I will add more, later on, with various widths). In order to determine the coordinates of the rect (only x changes, not y), I am using textureName.width * Time.deltaTime in the Update function.
Given the multiplication I have to do with deltaTime, the final calculation is going to 515 pixels, which, as a result, moves the texture plus 15 pixels than the original plan.
//This runs in OnGUI()
if (startCounting) {
GUI.Button (new Rect(Screen.width - infoX, Screen.height/2, infoPanel.width, infoPanel.height), infoPanel);
}
//This runs in the Update()
if (infoX <= infoPanel.width) {
infoX += infoPanel.width * Time.deltaTime;
}
Mind telling me how to deal with this? I also want to add a static duration. I want the sliding to always last for 0.7 seconds, regardless of the texture’s width (which is how the calculation on infoX will deal out). I tried (infoPanel.width*Time.deltaTime)/0.7f, but given the aforementioned problem, I can’t get a precise calculation.
What can I do in this case?