标签: unity-game-engine

允许带有刚体的碰撞器相互交叉

我正在制作汽车游戏。我的车发生了碰撞,但我不希望这些车发生碰撞 - 我希望这些车进入其他具有刚体和对撞机的汽车内部。有没有办法让我的汽车的碰撞器在物理交互中相互忽略?

unity-game-engine game-physics

-1
推荐指数
1
解决办法
206
查看次数

c#中使用不同图像的3D图像

我有不同角度的 2D 图像(一个特定对象的图像),我想合并所有三个图像并创建一个 3D 图像。

我怎样才能在 Unity 3D 中做到这一点?

.net c# unity-game-engine

-1
推荐指数
1
解决办法
2832
查看次数

三元运算符在 C# 中的工作原理

我最近尝试了 unity,并在其中一个 youtube 视频剪辑中看到了他们的代码如下:

    Random.Range(0, 2) == 0 ? -1 : 1;
Run Code Online (Sandbox Code Playgroud)

我理解 Random.Range() 但后面的部分是什么意思?先感谢您

c# unity-game-engine

-1
推荐指数
1
解决办法
4171
查看次数

我正在尝试修改 Unity 中的着色器,但收到“‘自定义/子空间外观’中的着色器错误:第 82 行(在 d3d11 上)无法识别的标识符‘输入’”?

我想立即声明我不经常使用着色器,而我正在使用的基本着色器 - 来自 Unity 论坛中的一个线程的力场着色器,是一个更旧的版本。然而,原来的“几乎”做了我想要的。

我想修改它以添加滚动效果以模拟速度,但奇怪的是我得到了“无法识别的标识符‘输入’”。IN Input 是一个普通变量.. 据说,在 Unity 的着色器中。到目前为止,这是我的代码:

Shader "Custom/SubspaceLook" {

Properties {
   _Color ("Main Color", Color) = (1,1,1,0.5)
   _MainTex ("Texture", 2D) = "white" {}
   _UVScale ("UV Scale", Range (0.05, 4)) = 1
   _UVDistortion ("UV Distortion", Range (0.01, 1)) = 0.5
   _Rate ("Oscillation Rate", Range (5, 200)) = 10
   _Rate2 ("Oscillation Rate Difference", Range (1, 3)) = 1.43
   _ZPhase ("Z Phase", Range (0, 3)) = 0.5
   _Scale ("Scale", Range (0.02, 2)) = 0.5
   _Distortion ("Distortion", Range (0, …
Run Code Online (Sandbox Code Playgroud)

shader unity-game-engine

-1
推荐指数
1
解决办法
4249
查看次数

如何通过脚本添加排序层

我正在尝试通过脚本添加排序层。

我可以通过脚本添加排序层吗?如何?

c# unity-game-engine unity-editor

-1
推荐指数
1
解决办法
1041
查看次数

当对象的 z 旋转超过限制时,函数不会触发

所以,我正在尝试制作一个大炮跟随鼠标的游戏。但是,我不希望它一直跟着它进入地下,所以我希望它在它到达那里之前停下来。我尝试使用夹钳方法,但没有奏效。我尝试了不同的方法。这是我的代码:`

using UnityEngine;

public class CannonPoint : MonoBehaviour {
   public GameObject cannon;
   public float rotateSpeed = 5;

   public float minAngle = -60;
   public float maxAngle = 60;

  void FixedUpdate(){
    Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    transform.rotation = Quaternion.LookRotation(Vector3.forward, mousePos - transform.position);
  }
  void Update(){
    if (transform.rotation.z > 71.759f) {
        Debug.Log ("not working");
        transform.rotation = Quaternion.Euler (transform.rotation.x, transform.rotation.y, 71.759f);
    }
    if (transform.rotation.z < -71.759f) {
        Debug.Log ("not working");
        transform.rotation = Quaternion.Euler (transform.rotation.x, transform.rotation.y, -71.759f);
    }
  }
}`
Run Code Online (Sandbox Code Playgroud)

当我这样做时,该功能不会触发。在更新中,inspector 告诉我旋转实际上大于 71.759,但是 Debug.Log 不触发 为什么会发生这种情况!我变得很困惑。谢谢! …

rotation unity-game-engine

-1
推荐指数
1
解决办法
52
查看次数

我如何统一更改玩家位置?

所以我是 C# 新手,我知道的不多,但我想知道如何改变玩家的位置,我只有这行代码:transform.position = 0.067, 1.52, -0.37;它向我抛出一个错误。

c# unity-game-engine

-1
推荐指数
1
解决办法
6036
查看次数

按键后如何执行操作?

我试图在按下大写字母后隐藏 Unity 中的文本,但它不起作用,它在“while”之前停止。我是一个不合格的程序员,所以有人更有经验吗?

private float TurnOffInfoText()
    {
       
      
        bool IsCapsPressed =   Input.GetKeyDown(KeyCode.CapsLock);
       
        while (IsCapsPressed == true)
        {
            
            EndOfGameText.enabled = false;
        }
      
        return 0;
        
}
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

-1
推荐指数
1
解决办法
39
查看次数

How can I calculate the time it's taking to do something inside a method?

public void SaveTest()
    {
        savingText.GetComponent<Text>().text = "Saving !";
        Save();
        savingTextLogInfo.GetComponent<Text>().text = "";
    }
Run Code Online (Sandbox Code Playgroud)

I want somehow to start a timer or something before calling the Save() method and after the Save() method to assign the time it took into the savingTextLogInfo text.

and I'm calling the SaveTest in some places in the game so in each time I want it first to reset the result of time and then to calculate again the time it's taking to make the Save …

c# unity-game-engine

-1
推荐指数
1
解决办法
41
查看次数

如何让相机与你的角色一起移动?

我做了一个第一人称游戏,我刚刚完成了让角色移动的代码,但是当他移动时,

相机停留在同一个地方,而不是随它移动。

有人知道我的问题是什么吗?

unity-game-engine

-1
推荐指数
1
解决办法
37
查看次数