Move FPS up/down one level in a building

Hi there,

I am actually using Player Relative Control Prefab from the Standard Assets (Mobile) Folder and i have a 3D model that have a few storey. The problem here is i am trying to move the character (Player Relative Control) Up/Down one storey upon clicking on the GUI Button of ‘Up’ or ‘Down’ respectively. But i would need to click on the ‘Down’ a few time before the character will actually move down by one storey. I am using the following Code:

character.transform.Translate(new Vector3(newPositionX, newPositionY, newPositionZ) * Time.deltaTime);

Someone can kindly advice me on what i should do to resolve this?

Thanks in advance!

Below is a sample of my problem code which should fire of when i click on the Button:

if (GUI.Button(new Rect(10, 60, 80, 30), "Down")) {

				//AutoFade.LoadLevel(null, 0, 1,;

				Debug.Log("Before current position: " + character.transform.position.y);

				for (int i = 0; i < floorHeightArrayList.Count; i++) {

					if ((character.transform.position.y - 1) <= float.Parse(floorHeightArrayList*.ToString())) {*

_ /if ((character.transform.position.y - 1) == float.Parse(floorHeightArrayList.ToString())) {*_

* newPositionX = character.transform.position.x;*

* newPositionY = float.Parse(floorHeightArrayList[i + 2].ToString()) + 1.0f;*

* newPositionZ = character.transform.position.z;*

* character.transform.position = new Vector3(newPositionX, newPositionY, newPositionZ);*

* break;*

_ }*/_

* newPositionX = character.transform.position.x;*

* newPositionY = float.Parse(floorHeightArrayList[i - 1].ToString()) + 1.0f;*

* newPositionZ = character.transform.position.z;*

* //Debug.Log("newPositionY: " + newPositionY);*

* character.transform.Translate(newPositionX, newPositionY, newPositionZ, Space.Self);*

* //character.transform.position = new Vector3(newPositionX, newPositionY, newPositionZ);*

* break;*

* }*

* }*

* Debug.Log("After current position: " + character.transform.position.y);*

* }*

if you want to instantly jump one floor when clicking the button, there’s no reason to multiply by deltaTime. You do that when you want to move at some steady rate over time, as in an update() function, and you multiply deltaTime by the velocity, not by a target position.

Assuming newPositionX/Y/Z are the point you want to go to one floor up/down, just remove the “*Time.deltaTime” bit entirely.