Why do Transform.Position only when i GetKeyDown(KeyCode.Space) ??

switch (i) {//transformacion despues del matched.
case 0:
if (Input.GetKey(KeyCode.Space)) {

					transform.position = Vector3.MoveTowards (transform.position, new Vector3 (p.origin.x, p.Box.bounds.max.y - transform.localScale.y - ClimbS.HeighAjustY, p.origin.z - cc.radius), PlayerStats.ClimbTime);
					//transform.rotation = Quaternion.Slerp (transform.rotation, p.transform.rotation, PlayerStats.ClimbRotateTimeM);
					//transform.rotation = Quaternion.Slerp (transform.rotation, p.transform.rotation, 5f);
					transform.rotation = Quaternion.Euler(p.transform.rotation.x ,p.transform.rotation.y , p.transform.rotation.z);
					anim.SetBool ("IsClimb", true);
					ClimbS.isClimbing = true;
				} else {
					ClimbS.isClimbing = false;
					p = null;


ok … the problem is that when I press the space does the Transform.Position but only moves a little and every time I give it moves a little more to reach the corresponding point … I do not know what happens and I carry some I’m thinking about this but I can not figure it out!

Your problem is at:


This command requires you keep pressing key.


 if(Input.GetKeyDown(Keycode) ){ does what you want here...}
 if(Input.GetKeyUp(Keycode)){ release the motion you did... }

You question should be like “Why does Input.GetKey() only work while you press the key?”

yea i use but is isnt still working