LoginSignup
0
0

More than 1 year has passed since last update.

ボタンを長押しでプレイヤーを右に移動

Posted at

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

public class RightButton : MonoBehaviour {
public float speed = 3;
bool push = false;

public void Update(){
    if(push){
        Move();
    }
}

public void PushDown(){
    push = true;
}

public void PushUp(){
    push = false;
}

public void Move(){
    Vector2 direction = new Vector2 (1.0f, 0).normalized;
    GetComponent<Rigidbody2D>().velocity = direction * speed;
}

}

ゲームオブジェクトにアタッチ後、ボタンに設置

0
0
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
0