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()
{
}
}
useGravityproperty, zeroing itsvelocity, or setting itsconstraintsto block unwanted motion? \$\endgroup\$