I enable rigid body components from code, but they are not working.
In the console, I can see the status is true, but objects are not falling down as they do usually.
this is part of my code, does anyone got any idea about this?
I enable rigid body components from code, but they are not working.
In the console, I can see the status is true, but objects are not falling down as they do usually.
this is part of my code, does anyone got any idea about this?
Hi @Dava,
Are those rigid body dynamic so they respond to gravity?
Try changing the order you call these two lines:
this.objects[i].collision.enabled = true;
this.objects[i].rigidbody.enabled = true;
Also you don’t need the activate()
method.
Hi @Leonidas
Yes, they are dynamic.
Changed the order, but still, the same, objects are not falling down
Just do be clear, when I do that in the inspector, it’s working without any problem
Most likely the order you are executing this is the issue then. Try isolating your code and/or execute with a delay to see what it expects to happen before it fires.
If you keep having issues, try sharing a sample project that reproduce this to take a look.
I think you are missing a “d” in enabled.
You should try this
this.objects[i].collision.enabled = true;
this.objects[i].rigidbody.enabled = true;
You were right, thanks Saif