Need help in translating javascript code into c#.
function DisableRagdoll() {
var rb:Rigidbody;
for (rb in GetComponentsInChildren(Rigidbody)) {
rb.enabled = false;
}
}
Answer by Ledifen · Aug 13, 2017 at 05:00 PM
I would like to help but I am a beginner and not that good with JavaScript. I'll give it a go nonetheless. I just need to know exactly what you're trying to do with (rb in GetComponentsInChildren(Rigidbody)) because I have no idea what the "in" represents.
I've read that you can't disable/enabled rigidbody, you can only delete/add them or put them to sleep.
For now, I only have this, but I can't verify it :
void DisableRagdoll() {
private Rigidbody rb; //I don't think it's the best idea to put that here. I would put that outside of any function (void). I'm not sure, thought. Just a feeling.
for (rb in GetComponentsInChildren<Rigidbody>) { //I don't know about "rb in"
rb.Sleep();
}
}
OR
void DisableRagdoll() {
private Rigidbody rb;
for (rb in GetComponentsInChildren<Rigidbody>) {
Destroy(rb);
}
}
Tell me if it helps :) I'm learning and would like to know if the "solutions" I'm coming up with work.
Your answer
Follow this Question
Related Questions
Could someone translate these to c#? 1 Answer
Trying to make a Parkour Platformer! 0 Answers
How to deal with repetetive code? 2 Answers
How do you continuously rotate an object? 1 Answer
Need help to put together 2 scripts 0 Answers