Rigidbody physics are not working after setting visible to true

I’m currently playing around with physics. So far everything works (instantiation, interaction, etc…), but when I have an inactive Rigidbody in my scene and set it to this.fallingCube.visible = true; it wont be affected by physics and just remain in place.

Original Post on Discord

by user 474974683163394049

I’d argue that’s by design, just because you make it visible doesn’t mean it necessarily should wake up, right? Though I’d have to check the behaviour in Unity as to what happens there / if it automatically wakes up

Checked it in Unity and (at least in Unity 2021.03.12f1) the Rigidbody component wakes up, as soon as you activate the gameObject (either via SetActive(true) or via the checkbox in the editor).

by user 474974683163394049

So in needle engine it falls, you set visible to false and then true again after x time and then it floats in air?

What happens if you nudge it with another physics object after? Does it wake up and fall again?

atm it stays in the air. I’ll try your suggestion, with physics interactions.

by user 474974683163394049

update: nope, the other physics object just passes through.

by user 474974683163394049

Do you think you can send the scene for debugging?

sure, do you want a Github repo or a build on Glitch?

by user 474974683163394049

The source would be helpful, you cna also zip the scene (via help/needle engine/zip scene)

Here you go :slightly_smiling_face: GitHub - FireDragonGameStudio/NeedleHandTracking

by user 474974683163394049

Thx gonna take a look at it tomorrow :slightly_smiling_face:

Thx, it’s not urgent btw, just smth that I stumbled upon :slightly_smiling_face:

by user 474974683163394049

Quick test in my little scene works. Looking at your project now.

Ok so the reason is/was the object starting off disabled and the core code initializing the “active” flag with the visible state (hence the object is marked as inactive)

in your code you then set “visible” to true which doesnt change the active flag so the components never get activated/enabled. I think I know how to change/fix this, testing a bit more here

One change you can do right now is changing this.cubeScattered05.visible = true; to GameObject.setActive(this.cubeScattered05, true, true);

Ok, I’ll do that, thanks :slightly_smiling_face: I thought that setting visible to true is the same as setActive(true), thought I read it in the docs :thinking:

by user 474974683163394049

It was like that in previous versions - looks like we forgot to update the docs :slightly_smiling_face:

Found it here btw. ^^

by user 474974683163394049

But the question is answered now, thx for the help, will update the tags :slightly_smiling_face:

by user 474974683163394049