弾を撃つプログラム 

Y座標の移動値を渡すことで斜めにも打てるようにした。 BulletInst(0); BulletInst(1); BulletInst(-1);Rigidbody2Dではtransform.forwardはZ値が無いため使用できないらしい。 void BulletInst(float y) { //作成 GameObject obj = Instantiate(bullet, tra…

360度 敵を生成

using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Collections.Generic; public class enemyInst : MonoBehaviour { float time; //生み出す敵のオブジェクト public GameObject EnemyObj; //プレイヤーのオブ…

マウスの方を向く

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Lookat : MonoBehaviour { Plane plane = new Plane(); float distance = 0; void Update() { // カメラとマウスの位置を元にRayを準備 var ray = Camera.mai…

当たったものを消す

using System.Collections; using System.Collections.Generic; using UnityEngine; public class tama : MonoBehaviour { private void OnCollisionEnter(Collision collision) { if(collision.gameObject.tag == "Enemy") { Destroy(collision.gameObject)…

弾を撃つ

using System.Collections; using System.Collections.Generic; using UnityEngine; public class fire : MonoBehaviour { public GameObject Tama; // Start is called before the first frame update void Start() { } // Update is called once per frame…

オブジェクトの移動と回転

using System.Collections; using System.Collections.Generic; using UnityEngine; public class move : MonoBehaviour { public float speed = 10.0f; public Rigidbody rb; // Start is called before the first frame update void Start() { rb = GetCom…

【Unity】 カメラをマウスで回転させる 上下に制限を付ける

using System.Collections; using System.Collections.Generic; using UnityEngine; //カメラにくっ付けるプログラム //参考にしたURL //http://mslgt.hatenablog.com/entry/2017/02/18/020630 public class CameraControll : MonoBehaviour { //マウスの座…