Paul_6
1
I want to make an object sleep if there's a key pressed. I have this script:
function Update()
{
if(Input.GetKey("D"))
{
Rigidbody.Sleep;
}
}
Is there any error in this?
Can someone help me?
Mike_3
3
Use rigidbody.Sleep(); instead of Rigidbody.Sleep;
I'm surprised it's not throwing an error or warning at you for it, but javascript has some weird quirks like that
Paul_6
4
I've tried both things, but I can't attache the script to my rigidbodies.
The console tells me an error:
BCE0020: An instance of type 'UnityEngine.Rigidbody' is required to access non static member 'Sleep'.
system
2
Rigidbody.Sleep only executes once every frame. So, if the player pushes D, it'll only stop for a frame, which I don't think you'd see.
So, maybe
function Update ()
{
while(Input.GetKey("D"))
{
Rigidbody.Sleep;
}
}
That might work, connect to the gameobject with the rigidbody =P.