Unity チュートリアル
1 Unitiy
Unitiy pro版は月額15000円なので注意
ウェブで遊べる場所 http://game16.net/tag/unity/
チュートリアル http://tutorial.unity3d.jp/
★http://dotinstall.com/lessons/basic_unity
ブロック崩しチュートリアル http://tutorial.unity3d.jp/archive/my-first-unity/
★4gamerチュートリアル http://www.4gamer.net/games/032/G003263/20111210004/
★Unitiy3Dゲームの作り方講座 http://unity3d-study.seesaa.net/
FPSチュートリアル http://ws.cis.sojo-u.ac.jp/~izumi/Unity_Documentation_jp/Documentation/3DPlatformTutorial_jp.pdf
マニュアル https://docs.unity3d.com/ja/current/Manual/UnityManual.html
チュートリアル https://www.youtube.com/watch?v=G9BdFZ2MCXc
https://unity3d.com/jp/learn/tutorials?_ga=2.58816239.311540188.1503564702-306553860.1503564529
アクションRPG http://www.nicovideo.jp/watch/sm30372960
最初 http://www.nicovideo.jp/watch/sm29750661
再生ボタンでエラーはいた時の解決方法 ★https://www.youtube.com/watch?v=xk-o7veL_6k
なにやらMicrosoftStadioにバグがあるらしくゲーム再生機能がきかないので動画の通りインストールしてください。
Monodelerop をダウンロード(Netframewarkと#GTK for Net)ダウンロードmicrosoft build toolダウンロード
UnitiyのEditの項目でPerfromanceの部分でeternaltoolでeternalscripttoolでmonoSDKにすればOK
ちなみにユニティのバージョンは2017.1.1f1だよー
ここさんこうになるよユーデミー
https://www.udemy.com/course/unityrpg2/
https://www.udemy.com/course/unityrpg/
アクションRPG 作り方 http://qiita.com/satewn/items/47e0e18bbb1442bf688c
FPSのチュートリアル https://gametukurikata.com/category/fps/page/2
大地の作り方 http://qiita.com/yando/items/ef76c200bb50005170d5
http://qiita.com/mokemokechicken/items/137c3a00d44841d3473e
カメラ追従http://www.atmarkit.co.jp/ait/articles/1505/18/news011_2.html
https://www.youtube.com/watch?v=gXpi1czz5NA
https://www.youtube.com/watch?v=nt55pxA7Snk
http://www.atmarkit.co.jp/ait/articles/1501/26/news035.html
http://calmery.hatenablog.com/entry/2016/04/23/215814
https://qiita.com/2dgames_jp/items/920ecd9386f3d96f58c4
https://www.youtube.com/watch?v=5GWj2LS4d8s
http://www.atmarkit.co.jp/ait/articles/1502/23/news036_4.html
https://docs.unity3d.com/ScriptReference/Collider-isTrigger.html
https://www.youtube.com/watch?v=In3YomPumGI&list=PLBz4z2-WuJKJsLGkp3_uAW4MgDKJEJNBA&index=3
プログラミング初心者のゆっくり達がゼロからゲームを作るようです
https://www.youtube.com/watch?v=gmMX0bhPoiQ
javaからC#
http://files.m2h.nl//js_to_c.php
youtubeにチュートリアルあるから英語でくぐろーね
Tutorial: How to make a level and xp system with unity
https://www.youtube.com/watch?v=ptcx-NnhQTI
https://www.youtube.com/watch?v=BqoWo7GTM8E
https://www.youtube.com/watch?v=mhHD9kboYC0
おすすめ書籍 Unity4入門 最新開発環境による3D制作 浅野裕一/荒川拓哉/森信虎
//キャラクターを動かすプログラム アニメーションコントローラーはboolを使ってる
スライドバーを使ってますよー。ボックスコライダー武器にはチェック 本体にはチェック入れないよー
敵も同様で攻撃モーションの所にSwordのコードを入れる。ボックスコライダのis_triggerに入れチェック
public classの名前も変更しよーね そうでないと動かないよー
学習するならユーデミーでUnityで検索しよーね
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PlayerContlloer : MonoBehaviour {
Animator anim;
public float speed = 10.0F;
public float rotationSpeed = 10.0F;
public int damage =20;
public Sword sword;
public int health = 1;
public Slider healthbar;
bool is_death;
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update () {
float translation = Input.GetAxis ("Vertical") * speed;
float straffe = Input.GetAxis ("Horizontal") * speed;
translation *= Time.deltaTime;
straffe *=Time.deltaTime;
transform.Translate(straffe,0,translation);
if(Input.GetMouseButton(0))
{
anim.SetBool("is_attack",true);
sword.Attack();
}
else
anim.SetBool("is_attack",false);
if(translation != 0)
{
anim.SetBool("is_running",true);
anim.SetBool("is_Idle",false);
}
else{
anim.SetBool("is_running",false);
anim.SetBool("is_Idle",true);
}
transform.Rotate(0,Input.GetAxis("Horizontal") * 3,0);
if (Input.GetKeyDown("escape"))
Cursor.lockState = CursorLockMode.None;
}
public virtual void Hit(){
health--;
healthbar.value = health;
if (health <= 0) {
anim.SetBool("is_death",true);
Death();
}
}
public void OnTriggerEnter(Collider otherCollider){
if(otherCollider.GetComponent<Sword>()!=null){
if (otherCollider.GetComponent<Sword> ().IsAttacking) {
Hit ();
}
}
}
public void Death(){
is_death = true;
}
}
//Swordのソースコード 武器につけよーね
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Sword : MonoBehaviour {
public float swingingSpeed = 2f;
public float cooldownSpeed = 2f;
public float attackDuration = 0.35f;
public float cooldownDuration = 0.5f;
private Quaternion targetRotation;
public float cooldownTimer;
private bool isAttacking;
public bool IsAttacking{
get{
return isAttacking;
}
}
// Use this for initialization
void Start () {
targetRotation = Quaternion.Euler (0, 0, 0);
}
// Update is called once per frame
void Update () {
transform.localRotation = Quaternion.Lerp (transform.localRotation, targetRotation, Time.deltaTime * (isAttacking ? swingingSpeed : cooldownSpeed));
cooldownTimer -= Time.deltaTime;
}
public void Attack(){
if (cooldownTimer > 0f) {
return;
}
targetRotation = Quaternion.Euler (0, 0, 270);
cooldownTimer = cooldownDuration;
StartCoroutine (CooldownWait());
}
private IEnumerator CooldownWait(){
isAttacking = true;
yield return new WaitForSeconds (attackDuration);
isAttacking = false;
targetRotation = Quaternion.Euler (0, 0, 0);
}
}
//敵のAIスクリプト
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class EnemyAI : MonoBehaviour {
public Transform Player;
static Animator anim;
public float totalHealth;
public float currentHealth;
public float expGranted;
public float attackDamege;
public float attackSpeed;
public float movementSpeed;
public Sword sword;
public int health = 1;
public Slider healthbar;
bool is_death;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
Vector3 direction = Player.position - this.transform.position;
float angle = Vector3.Angle (direction, this.transform.forward);
if(Vector3.Distance(Player.position,this.transform.position) < 10 && angle < 30)
{
this.transform.rotation = Quaternion.Slerp (this.transform.rotation, Quaternion.LookRotation (direction), 0.1f);
anim.SetBool ("is_Idle", false);
if(direction.magnitude > 5)
{
this.transform.Translate (0, 0, 0.05f);
anim.SetBool ("is_walk", true);
anim.SetBool ("is_attack", false);
}
else{
anim.SetBool ("is_attack", true);
anim.SetBool ("is_walk", false);
sword.Attack();
}
}
else{
anim.SetBool ("is_Idle", true);
anim.SetBool ("is_walk", false);
anim.SetBool ("is_attack", false);
}
}
public void GetHit(float damage){
anim.SetInteger("is_damage",3);
health--;
StartCoroutine(RecoverFromHit());
}
IEnumerator RecoverFromHit()
{
yield return new WaitForSeconds (0.1f);
anim.SetInteger("is_damage", 0);
}
public virtual void Hit(){
health--;
anim.SetInteger("is_damage",3);
healthbar.value = health;
if (health <= 0) {
anim.SetBool("is_death",true);
Death();
}
}
public void OnTriggerEnter(Collider otherCollider){
if(otherCollider.GetComponent<Sword>()!=null){
if (otherCollider.GetComponent<Sword> ().IsAttacking) {
Hit ();
}
}
}
public void Death(){
is_death = true;
Destroy (gameObject, 2f);
}
}
チュートリアルのレベルアップシステム 経験値とかわかるからねー
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LevelSystem : MonoBehaviour {
public int XP;
public int currentLevel;
// Update is called once per frame
void Update () {
UpdateXp (5);
}
public void UpdateXp(int xp)
{
XP += xp;
int curlvl = (int)(0.1f * Mathf.Sqrt (XP));
if (curlvl != currentLevel) {
currentLevel = curlvl;
}
int xpnextlevel = 100 * (currentLevel + 1) * (currentLevel + 1);
int diffencexp = xpnextlevel - XP;
int totaldiffence = xpnextlevel - (100 * currentLevel * currentLevel);
}
}
経験値パート2
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LevelUPSystem : MonoBehaviour {
public int level;
public float experlence;
public float experlenceRequlred;
public float Health;
// Use this for initialization
void Start () {
level = 1;
Health = 100;
experlence = 0;
experlenceRequlred = 100;
}
// Update is called once per frame
void Update () {
Exp ();
if (Input.GetKeyDown (KeyCode.E))
{
experlence += 100;
}
}
void RankUp(){
level += 1;
experlence = 0;
switch (level) {
case 2:
Health = 200;
experlenceRequlred = 200;
break;
case 3:
Health = 300;
experlenceRequlred = 300;
print ("congratulations! you have hit level3 on your character!");
break;
}
}
void Exp(){
if (experlence >= experlenceRequlred)
RankUp ();
}
}
プレイヤーを動かす方法のスクリプト
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[System.Serializable]
public class PlayerContlloer : MonoBehaviour {
Animator anim;
public float speed = 10.0F;
public float rotationSpeed = 10.0F;
public Sword sword;
public GameObject model;
public Slider healthbar;
bool is_death;
public int Health = 1;
private Rigidbody PlayerRigibody;
public int level;
public float experlence;
public float experlenceRequlred;
public int damage;
public int armor;
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
PlayerRigibody = GetComponent<Rigidbody> ();
Cursor.lockState = CursorLockMode.Locked;
level = 1;
Health = 100;
experlence = 0;
experlenceRequlred = 100;
}
// Update is called once per frame
void Update () {
Exp();
float translation = Input.GetAxis ("Vertical") * speed;
float straffe = Input.GetAxis ("Horizontal") * speed;
translation *= Time.deltaTime;
straffe *=Time.deltaTime;
transform.Translate(straffe,0,translation);
if(Input.GetMouseButton(0))
{
anim.SetBool("is_attack",true);
sword.Attack();
}
else
anim.SetBool("is_attack",false);
if(translation != 0)
{
anim.SetBool("is_running",true);
anim.SetBool("is_Idle",false);
}
else{
anim.SetBool("is_running",false);
anim.SetBool("is_Idle",true);
}
transform.Rotate(0,Input.GetAxis("Horizontal") * 3,0);
if (Input.GetKeyDown("escape"))
Cursor.lockState = CursorLockMode.None;
}
public virtual void Hit(){
Health--;
healthbar.value = Health;
if (Health <= 0) {
anim.SetBool("is_death",true);
Death();
}
}
public void OnTriggerEnter(Collider otherCollider){
if(otherCollider.GetComponent<Sword>()!=null){
if (otherCollider.GetComponent<Sword> ().IsAttacking) {
Hit ();
}
}
}
public void Death(){
is_death = true;
}
public void RankUp(){
level += 1;
experlence = 0;
switch (level) {
case 2:
Health = 200;
experlenceRequlred = 200;
break;
case 3:
Health = 300;
experlenceRequlred = 300;
print ("congratulations! you have hit level3 on your character!");
break;
}
}
void Exp(){
if (experlence >= experlenceRequlred)
RankUp ();
}
}