Skip to main content
Formatting
Source Link
DMGregory
  • 141k
  • 23
  • 258
  • 401

disabling Disabling RigidBody component

I'm trying to create a mechanic in my puzzle game in which if the player clicks on one of the flying game objects, the object's gravity would be enabled and world physics would be applied to it. Initially, I thought I could use the 'enabled' feature to create such a mechanic but I noticed that the RigidBody class does not contain 'enabled'.

Could there be any other way that would allow me to disable the GameObject's gravity or RigidBody component when it is instantiated?

using System.Collections;

using System.Collections.Generic; using UnityEngine;

[RequireComponent(typeof(Rigidbody))] public class Plane : MonoBehaviour { private bool clicked = false; [SerializeField] private Rigidbody rb; // Start is called before the first frame update void Start() { rb = GetComponent(); rb.enabled = false; }

using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class Plane : MonoBehaviour
{
    private bool clicked = false;
    [SerializeField] private Rigidbody rb;
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
        rb.enabled = false;
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

}

disabling RigidBody component

I'm trying to create a mechanic in my puzzle game in which if the player clicks on one of the flying game objects, the object's gravity would be enabled and world physics would be applied to it. Initially, I thought I could use the 'enabled' feature to create such a mechanic but I noticed that the RigidBody class does not contain 'enabled'.

Could there be any other way that would allow me to disable the GameObject's gravity or RigidBody component when it is instantiated?

using System.Collections;

using System.Collections.Generic; using UnityEngine;

[RequireComponent(typeof(Rigidbody))] public class Plane : MonoBehaviour { private bool clicked = false; [SerializeField] private Rigidbody rb; // Start is called before the first frame update void Start() { rb = GetComponent(); rb.enabled = false; }

// Update is called once per frame
void Update()
{
    
}

}

Disabling RigidBody component

I'm trying to create a mechanic in my puzzle game in which if the player clicks on one of the flying game objects, the object's gravity would be enabled and world physics would be applied to it. Initially, I thought I could use the 'enabled' feature to create such a mechanic but I noticed that the RigidBody class does not contain 'enabled'.

Could there be any other way that would allow me to disable the GameObject's gravity or RigidBody component when it is instantiated?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class Plane : MonoBehaviour
{
    private bool clicked = false;
    [SerializeField] private Rigidbody rb;
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
        rb.enabled = false;
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
Source Link

disabling RigidBody component

I'm trying to create a mechanic in my puzzle game in which if the player clicks on one of the flying game objects, the object's gravity would be enabled and world physics would be applied to it. Initially, I thought I could use the 'enabled' feature to create such a mechanic but I noticed that the RigidBody class does not contain 'enabled'.

Could there be any other way that would allow me to disable the GameObject's gravity or RigidBody component when it is instantiated?

using System.Collections;

using System.Collections.Generic; using UnityEngine;

[RequireComponent(typeof(Rigidbody))] public class Plane : MonoBehaviour { private bool clicked = false; [SerializeField] private Rigidbody rb; // Start is called before the first frame update void Start() { rb = GetComponent(); rb.enabled = false; }

// Update is called once per frame
void Update()
{
    
}

}