Monday, July 2, 2018

c# - Unity Renderer.bounds issue?


I would like to make rend.bounds.max.y be always equal to 20 on collision no matter what, using the script below. But it seems that I can't set it manually and the script has no effect on my GameObject.


Script:


public class ClassKey : MonoBehaviour{

void Start()
{
rend = GetComponent();

}

void OnCollisionEnter(Collision col)
{
//more code
rend.bounds.max.y = 20;
//more code
}
}


What I want to achieve: "Change rend.bounds.max.y to 20 when colliding (and keep the new value forever), and let rend.bounds.max.x and rend.bounds.max.z vary freely when colliding"


The problem: Renderer.bounds is read only... How can I go around this?




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...