2Dシューティング_移動用スクリプトの作成
+ボタン押下でコードを確認できます!
エディタでアタッチし忘れている可能性が高いです。
- Movement
- This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement : MonoBehaviour { //このスクリプトはBoss以外のキャラ移動を扱う(PlayerもEnemyも) [SerializeField] protected float xSpeed = 1.5f, ySpeed = 1.5f; private Vector2 moveDelta; protected void CharacterMovement(float x, float y) { moveDelta = new Vector2(x * xSpeed, y * ySpeed); transform.Translate(moveDelta.x, moveDelta.y, 0); } }