Skip to content

Instantly share code, notes, and snippets.

@am1tanaka
Created March 13, 2018 04:57
Show Gist options
  • Select an option

  • Save am1tanaka/20c28e7c6e6eb14ed9cccb3f2dbddd57 to your computer and use it in GitHub Desktop.

Select an option

Save am1tanaka/20c28e7c6e6eb14ed9cccb3f2dbddd57 to your computer and use it in GitHub Desktop.
Unity: マウス操作でオブジェクトを動かすスクリプト。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class move : MonoBehaviour {
void Update () {
Vector3 mpos = Input.mousePosition;
mpos.z = -Camera.main.transform.position.z;
Vector3 wpos = Camera.main.ScreenToWorldPoint (mpos);
transform.position = wpos;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment