奇怪的行为块放置,Raycast,hit.normal。 C#
Weird behaviour block placement, Raycast, hit.normal. C#
我正在尝试制作一个简单的方块放置脚本。
静态时一切似乎都在工作(当它没有刚体时)
但是当我添加刚体并尝试在其上放置一个块时,它不会出现。当我查看层次结构时,它会到达地下 (Terrian) 或已放置块内的一个非常奇怪的位置。
这是脚本:
var TheBlock = Instantiate(Blocks[0], hit.transform.position +hit.normal / 4, Quaternion.identity);
有谁知道如何解决这种奇怪的行为/解释为什么会这样?
提前致谢!
-Shinevision
but when i add the rigidbody and i try to place a block on it, it
won't appear. when i look in the hierarchy it goes to a very strange
position under the ground (Terrian) or inside a already placed block.
很可能在 Rigidbody
附着时,重力正在拉动 Object。即使在地形下,默认重力也会将其拉下。实例化对象后禁用useGravity
。
var TheBlock = Instantiate(Blocks[0], hit.transform.position + hit.normal / 4, Quaternion.identity);
TheBlock.GetComponent<Rigidbody>().useGravity = false;
我正在尝试制作一个简单的方块放置脚本。 静态时一切似乎都在工作(当它没有刚体时) 但是当我添加刚体并尝试在其上放置一个块时,它不会出现。当我查看层次结构时,它会到达地下 (Terrian) 或已放置块内的一个非常奇怪的位置。
这是脚本:
var TheBlock = Instantiate(Blocks[0], hit.transform.position +hit.normal / 4, Quaternion.identity);
有谁知道如何解决这种奇怪的行为/解释为什么会这样?
提前致谢!
-Shinevision
but when i add the rigidbody and i try to place a block on it, it won't appear. when i look in the hierarchy it goes to a very strange position under the ground (Terrian) or inside a already placed block.
很可能在 Rigidbody
附着时,重力正在拉动 Object。即使在地形下,默认重力也会将其拉下。实例化对象后禁用useGravity
。
var TheBlock = Instantiate(Blocks[0], hit.transform.position + hit.normal / 4, Quaternion.identity);
TheBlock.GetComponent<Rigidbody>().useGravity = false;