我正在制作汽车游戏。我的车发生了碰撞,但我不希望这些车发生碰撞 - 我希望这些车进入其他具有刚体和对撞机的汽车内部。有没有办法让我的汽车的碰撞器在物理交互中相互忽略?
我有不同角度的 2D 图像(一个特定对象的图像),我想合并所有三个图像并创建一个 3D 图像。
我怎样才能在 Unity 3D 中做到这一点?
我最近尝试了 unity,并在其中一个 youtube 视频剪辑中看到了他们的代码如下:
Random.Range(0, 2) == 0 ? -1 : 1;
Run Code Online (Sandbox Code Playgroud)
我理解 Random.Range() 但后面的部分是什么意思?先感谢您
我想立即声明我不经常使用着色器,而我正在使用的基本着色器 - 来自 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) 我正在尝试通过脚本添加排序层。
我可以通过脚本添加排序层吗?如何?
所以,我正在尝试制作一个大炮跟随鼠标的游戏。但是,我不希望它一直跟着它进入地下,所以我希望它在它到达那里之前停下来。我尝试使用夹钳方法,但没有奏效。我尝试了不同的方法。这是我的代码:`
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 不触发 为什么会发生这种情况!我变得很困惑。谢谢! …
所以我是 C# 新手,我知道的不多,但我想知道如何改变玩家的位置,我只有这行代码:transform.position = 0.067, 1.52, -0.37;它向我抛出一个错误。
我试图在按下大写字母后隐藏 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) 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 …
我做了一个第一人称游戏,我刚刚完成了让角色移动的代码,但是当他移动时,
相机停留在同一个地方,而不是随它移动。
有人知道我的问题是什么吗?