主摄像头只能看到地面

时间:2019-05-13 19:46:01

标签: unity3d

我做一个3D游戏,我的枪只射击地面,即使我选择其他物体射击也是如此。我的地面旋转,可能会影响游戏吗?我应该在主相机中添加一些内容吗?

using UnityEngine;

public class Gun : MonoBehaviour
{
    public float damage = 10f;
    public float range = 100f;
    public Camera fpsCam;


    // Start is called before the first frame update
 

    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            Shoot();

        }
        
    }
    void Shoot()
    {
        RaycastHit hit;
       if( Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
        {
            Debug.Log(hit.transform.name);
        }
    }
}

picture ground

0 个答案:

没有答案