Post date: Oct 18, 2015 10:31:41 AM
最近流行のLeague of Legendsや、
SEGAの出したアーケードゲーム Wonderland Warsのジャンルは、
MOBA(Multiplayer online battle arena)って言うらしい。
ちょいとゲームシステムのほうに興味が出たので、ちょこちょこ作ってみる。
まずは移動。
キャラから見てではなく、カメラから見て右へ左へと動くやり方。
ダークソウルみたいな感じ。
移動のソースはこんな感じで。
charMaster.cs
using UnityEngine;
using System.Collections;
public class charMaster : MonoBehaviour {
public Transform cameraTransform;
private float spead = 0.0f;
private Animator animator;
private bool runID;
// Use this for initialization
void Start () {
animator = GetComponent<Animator>();
spead = 0.1f;
}
// Update is called once per frame
void Update () {
if ((Input.GetAxis("Horizontal") != 0) || (Input.GetAxis("Vertical") != 0)) {
//移動
Vector3 targetDirection = (cameraTransform.right * Input.GetAxis("Horizontal")) + (cameraTransform.forward * Input.GetAxis("Vertical"));
transform.rotation = Quaternion.LookRotation(new Vector3(targetDirection.x, 0, targetDirection.z));
transform.Translate(Vector3.forward * spead);
//走りモーション
animator.SetBool("running", true);
}
else {
//待機モーション
animator.SetBool("running", false);
}
}
}
これだと、カメラ置いてけぼりなのでカメラ追従のソース。
camera.cs
using UnityEngine;
using System.Collections;
public class camera: MonoBehaviour {
public GameObject player;
private Vector3 offset;
// Use this for initialization
void Start() {
this.offset = this.transform.position - this.player.transform.position;
}
// Update is called once per frame
void Update() {
this.transform.position = new Vector3(this.player.transform.position.x + this.offset.x, this.player.transform.position.y + this.offset.y, this.player.transform.position.z + this.offset.z);
}
}
とりあえず、これで動ける。
今回の操作はゲームパッドのステックにも対応。
というより、ステック推奨になりそう。
あ、あとステック対応させているから
InportManagerの上下左右ステックの遷移速度の高速化を忘れずに。
これしないと氷床のようにつるつる滑ります。
InportManager
Horaizontal
Sensitivity 3 → 0.1
Vertical
Sensitivity 3 → 0.1
あと、撮影したMMD画像とかそのうちここにも挙げるかもです。
せっかく場所あるので、使わなければ。