0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

爆速でオブジェクトを動かすスクリプト

Last updated at Posted at 2020-02-06

standardAssetsを入れる暇がない場合、
こんな感じのスクリプトを書けば、「とりあえず前後に移動して、左右に旋回する」ことができる。

マイクラとかみたいに、ジャンプなどは、とりあえずstandardAssetsを入れるか、
キャラクターコントローラーを使ったスクリプトが望ましい。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Move_player: MonoBehaviour
{

    public float MoveSpeed;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.UpArrow))
        {
            transform.position += transform.forward * MoveSpeed;
        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            transform.position += transform.forward * -1 * MoveSpeed;
        }
        if (Input.GetKey(KeyCode.RightArrow))
        {
            transform.Rotate(0, 5, 0);
        }
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            transform.Rotate(0, -5, 0);
        }
    }
}

gitHubに置いたMove_playerのリンクはここから

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?