使用下面的脚本,我想让rend.bunds.max.y在碰撞时总是等于20。但我似乎不能手动设置它,脚本对我的GameObject没有任何影响。
脚本:
public class ClassKey : MonoBehaviour{
void Start()
{
rend = GetComponent<Renderer>();
}
void OnCollisionEnter(Collision col)
{
//more code
rend.bounds.max.y = 20;
//more code
}
}我想要实现的是:“碰撞时将rend.bounds.max.y改为20 (并永远保持20 ),碰撞时让rend.bounds.max.x和rend.bounds.max.z自由变化。”
问题: Renderer.bounds是只读的……我怎么才能绕过这个问题呢?
发布于 2015-11-26 03:08:58
你不能改变Renderer.bounds。您可以尝试更改Mesh.bounds
发布于 2015-11-26 03:09:20
看起来Unity中渲染器的边界是只读的。根据http://docs.unity3d.com/ScriptReference/Renderer-bounds.html的文档,
渲染器是
渲染器的边界体积(只读)。
我目前还没有找到任何方法来更改Unity文档中的渲染器设置,但当我这样做时,我会相应地更改我的答案。
https://stackoverflow.com/questions/33924168
复制相似问题