제가 여러분들 도움으로 유니티2D로 방향에 따라서 총알이 나가는 것도 구현했는데 이제는 맵이동할떄 그 총알이 나가기 위해서 같이 붙여놓았던 Gizmo를 넣고 하니까 맵이동이 안되네요 왜그럴까요 ㅠㅠ따로 할때는 잘됬는데 합치면 맵이동이 안되요 스크립트 같이 올리니까 고수님들 도움이 절실해요@@@

참고로 각각 스크립트 따로 만들어서 넣은거예요 아래에는 보기편하게 그냥 쭉 붙여놓은겁니다.

<캐릭터에 이처럼 Gizmo가 붙어서 움직이게된다>

viewimage.php?id=2abcdd23dad63db0&no=24b0d769e1d32ca73ced85fa11d02831a10d3d354cfd32a273f839b079c09d8e5c7a08bd31744a9fb9e43b5ac637a0ed57bedd17b5c35b95f098dd261c3c3020e003



Gizmo를 통해서 방향 확인 스크립트

public class MyGizmo : PlayerMove

{

    public float dist = 0.5f;

    public Transform tr;

    public Transform target;

    private Vector3 vector;


    public Color _color = Color.red;

    public float _radius = 0.3f;


    private void OnDrawGizmos()

    {

        Gizmos.color = _color;

        Gizmos.DrawSphere(transform.position, _radius);

    }

        // Start is called before the first frame update

        void Start()

    {

        tr = GetComponent();

    }


    // Update is called once per frame

    void Update()

    {

        tr.position = target.position - (Vector3.forward * dist);

       if (Input.GetAxisRaw("Vertical") != 0 || Input.GetAxisRaw("Horizontal") != 0)

        {

            vector.Set(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"), transform.position.z);

            if(vector.x <=1&&vector.x>0)

            {

                tr.rotation = Quaternion.Euler(0, 0, 270); 

            }

            if (vector.x >= -1 && vector.x

            {

                tr.rotation = Quaternion.Euler(0, 0, 90);

            }

            if (vector.y <= 1 && vector.y > 0)

            {

                tr.rotation = Quaternion.Euler(0, 0, 0);

            }

            if (vector.y >= -1 && vector.y

            {

                tr.rotation = Quaternion.Euler(0, 0, 180);

            }


        }

    }

}

총알 생성 스크립트
public class CreatBullet : MonoBehaviour
{
    public GameObject bullet;
    public Transform firepos;

    

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Fire();
        }
       
    }
    void Fire()
    {
        StartCoroutine(this.Creatbullet());
    }
    IEnumerator Creatbullet()
    {
        Instantiate(bullet, firepos.position, firepos.rotation);
        yield return null;
    }

}


맵이동 스크립트
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;


public class TransferMap : MonoBehaviour
{
    public Transform target;
    private PlayerMove thePlayer;
    public string TransferMapName;
    
    // Start is called before the first frame update
    void Start()
    {
        
        thePlayer = FindObjectOfType();
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if(collision.gameObject.name=="Player")
        {
            thePlayer.currentMapName = TransferMapName;
            thePlayer.transform.position = target.transform.position;
            
        }
    }

}