Skip to content

Instantly share code, notes, and snippets.

@KRNKRS
Created March 24, 2013 03:10
Show Gist options
  • Select an option

  • Save KRNKRS/5230318 to your computer and use it in GitHub Desktop.

Select an option

Save KRNKRS/5230318 to your computer and use it in GitHub Desktop.
座標移動訂正コード
void Update()
{
if (transform.position.x >= 0.5 ||
transform.position.x <= -4)
{
Vel = 0;
}
#region キー入力
//右が押されたら
if (Input.GetKeyDown(KeyCode.RightArrow) &&
!MoveFlag)
{
Vel = 0.2f;
}
else
{
MoveFlag = false;
}
//左が押されたら
if (Input.GetKeyDown(KeyCode.LeftArrow) &&
!MoveFlag)
{
Vel = -0.2f;
}
#endregion
Debug.Log(Vel);
transform.Translate(Vel, 0, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment