- Home /
Script Error
Hello guys so im making a script that when i press a particular key rigid body enables on a object Im new to scripting and i wonder if you can help me finish this script
(sorry for my english because im Slovenian :3)
wonder if you can help me finish this script
So lets see the start of it :P
lmao what is the question??! help you finish what?? your title is "Script error" yet your question body is something totally different. Please ask better, if you can't handle English then feel free to write Slovenian and we'll translate!
Answer by clunk47 · Oct 24, 2013 at 05:35 PM
How the hell are we supposed to know what you're talking about when you don't post this script you've "made"...
using UnityEngine;
using System.Collections;
public class RigidbodyTest : MonoBehaviour
{
void Update ()
{
if(Input.GetKeyDown (KeyCode.R))
rigidbody.isKinematic = !rigidbody.isKinematic;
if(!rigidbody.isKinematic && rigidbody.IsSleeping())
rigidbody.WakeUp();
}
}
It's worth mentioning that, for some reason you can't enable/disable a rigidbody component directly, like:
target.GetComponent<RigidBody>().enabled = true/false;
Ins$$anonymous$$d you either destroy the whole component if you wanna disable it and add it when you wanna enable it.
Or just set the is$$anonymous$$inematic
to true for disable, and false for enable.