FixedUpdate()
オブジェクトに物理運動をさせるときは、FixedUpdateを使う。
void FixedUpdate (){ if(GameManager.instance.play){ float horizontal = Input.GetAxis("Horizontal"); // 速度上限を決める if(rigidbody2D.velocity.x > minWalkForce && rigidbody2D.velocity.x < maxWalkForce){ this._moveCharactor(Vector2.right * walkForce * horizontal); } if(rigidbody2D.velocity.y < maxFlyForce){ if(Input.GetKeyDown(KeyCode.Space)){ // if (Input.GetKeyDown("space")) と同じ if(floor_Below){ this._moveCharactor(Vector2.up * flyForce); }else{ this._moveCharactor(Vector2.up * -1 * flyForce); } // 前進するときの音 AudioManager.instance.BallMoveSound(); iTween.PunchScale(gameObject,iTween.Hash("amount", new Vector3(0.1f,0.1f,0),"time",1.7f,"easetype",iTween.EaseType.easeOutCubic)); } } Vector2 temp = transform.position; temp.x = Mathf.Clamp(temp.x,-9,9); transform.position = temp; } }
http://magicbullet.hatenablog.jp/entry/2013/09/10/223118
追記2015/05/06
FixedUpdate内では、Time.deltaTimeを掛けなくて良い。
FixedUpdateがフレームとは別の概念で動作している。ameblo.jp