1.概要
開始:19:59
終了:1:40
参加者:ちょばに、ちょむ、ぱうちゃん、やすみー、わきわき
2.わきわきのイラストレーター講座(その1)
今日の講座:わきわきのかまいたちを作りたい!
やり方
1.まず楕円ツールを選んで楕円を2個作る(色を変えれる)


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");
}
}
}
}
以上になります。今回も勉強会お疲れ様でした!!
書記:やすみー