2
3

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.

関西Unity10期勉強会 第3回(6/22)

Posted at

1.概要

開始:19:59
終了:1:40

参加者:ちょばに、ちょむ、ぱうちゃん、やすみー、わきわき

2.わきわきのイラストレーター講座(その1)

今日の講座:わきわきのかまいたちを作りたい!

やり方

1.まず楕円ツールを選んで楕円を2個作る(色を変えれる)

スクリーンショット 2018-06-22 23.30.47.pngスクリーンショット 2018-06-22 23.31.23.png

2.いい感じに重ねる
スクリーンショット 2018-06-22 23.32.15.png

3.両方選択する
スクリーンショット 2018-06-22 23.32.24.png

4.シェイプ形成ツールで重なったところが切り取られる
スクリーンショット 2018-06-22 23.32.24.png

スクリーンショット 2018-06-22 23.33.41.png

2わきわきのゲームの武器獲得の仕組みが知りたい!

わきわきのゲーム→https://www.youtube.com/watch?v=f0HUcDfaOXA


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

public class test : MonoBehaviour {

    float item1 = 1.0f;            //アイテム指定用の変数(確率)を入れる箱
    public GameObject punch;    //パンチ、キックのゲームオブジェクトを定義
    public GameObject kick;


    // Use this for initialization
    void Start () {
        
    }
    
    // Update is called once per frame
    void Update () {
        

        //キー入力がある かつ “item1”によってどのアイテムを生成するかを選択(割合操作)(Invoke)
        if (Input.GetKeyDown(KeyCode.Slash) && 1.0f <= item1 && item1 < 4.0f ){
            Invoke(punch1", 0);
        }

        if (Input.GetKeyDown(KeyCode.Slash) && 4.0f <= item1 && item1 < 10.0f ){
            Invoke(kick1, 0);
        }


        //キー入力があったら“1tem1"内の数値をランダムで変更(random)
        if (Input.GetKeyDown (KeyCode.Slash) ) {
            item1 = Random.Range (1.0f, 10.0f);
        }



    }


    //以下自分で定義したアクション
    //パンチ、キックのオブジェクトをスクリプトをつけた人の場所に生成(Instantiate)
    void punch1(){
        Instantiate (punch, transform.position, transform.rotation);
    }
    void kick1(){
        Instantiate (kick, new Vector2 (transform.position.x, transform.position.y - 0.5f), transform.rotation);
    }
        
}

※勉強会ではわきわきから直々に教えてもらいました。

3.SendMessegeでダメージを別のスクリプトでやろうと思ってもうまくできない...

原因:SendMessegeを送る関数が違うスクリプトで同じ名前で作られていた。

以下に少し簡単に失敗例を書きます

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

public class test1 : MonoBehaviour {

void Start(){

}

void Update(){

if(hit.if (hit.collider.tag == "Enemy") {
        hit.collider.SendMessage ("Damage1");
}
}
}

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

public class test2 : MonoBehaviour {

void Start(){

}

void Update(){

}

void Damage1(){

//何かしらの処理

}
}


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

public class test3 : MonoBehaviour {

void Start(){

}

void Update(){

}

void Damage1(){
//何かしらの別の処理
}
}

4.弾をどうやって飛ばそうか?

解決:やすみーのやつを真似すればできるんじゃない?

以下やすみーの魔法を飛ばすコード


using UnityEngine;
using System.Collections;

public class Mahou1 : MonoBehaviour {

	// Mahou prefab
	public GameObject WhityBomb;

	// 発射点
	public Transform unitychan;

	// 魔法の速度
	public float speed = 100;

	RaycastHit hit;


	// Use this for initialization
	void Start () {
		
	}

	// Update is called once per frame
	void Update () {
		// z キーが押された時
		if (Input.GetKeyDown (KeyCode.A) ) {
			
			// 魔法の複製
			GameObject WhityBombs = GameObject.Instantiate (WhityBomb)as GameObject;
			//5秒後に破壊
			Destroy (WhityBombs, 5);

			Vector3 force;
			force = this.gameObject.transform.forward * speed;
			// Rigidbodyに力を加えて発射
			WhityBombs.GetComponent<Rigidbody> ().AddForce (force);
			// 魔法の位置を調整
			WhityBombs.transform.position = unitychan.position;


			Mahou ();
		}
	}

	void Mahou(){	

	Vector3 center = new Vector3 (Screen.width / 2, Screen.height / 2, 0);
		Ray ray = Camera.allCameras[0].ScreenPointToRay (center);
		float distance = 10f;
		if (Physics.Raycast (ray, out hit, distance)) {
			if (hit.collider.tag == "Enemy") {
				hit.collider.SendMessage ("Damage1");

			}
		}
	}
}

以上になります。今回も勉強会お疲れ様でした!!
                                       書記:やすみー

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?