Posisi beku kaku2d
public Rigidbody2D rb;
void Start()
{
rb.constraints = RigidbodyConstraints2D.FreezeAll;
}
Comfortable Capybara
public Rigidbody2D rb;
void Start()
{
rb.constraints = RigidbodyConstraints2D.FreezeAll;
}
//For 3D Games, 2D is similar but uses Rigidbody2D, RigidbodyConstraints2D
public GameObject obj; // this is the actual game obj. Drag & drop in inspector
// or if this script is on the object, then get the transform.gameObject.
private Rigidbody rb; // this will reference the physics
void Start()
{
rb = obj.GetComponent<Rigidbody>(); // grabs the rigidbody
rb.constraints = RigidbodyConstraints.FreezeAll; // freeze rotation and pos
// This will freeze as script is loaded. You will have to use
// RigidyBodyConstraints.None to free physics.
{
rigidbody.constraints = RigidbodyConstraints.FreezeRotation;