Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Type or namespace of ConfigurableJoint does not exist

Discussion in 'Scripting' started by lea_palucca, Sep 7, 2023.

  1. lea_palucca

    lea_palucca

    Joined:
    Jun 16, 2022
    Posts:
    2
    Hi,

    I am currently trying to create a Button in VR that triggers an event when pressed. This button uses a configurable joint for the physics (which work fine so far). However, when I try to include the joint in my script to get the linear Limit set in the editor, the editor throw an error upon compiling:

    Assets\Scripts\PhysicsButton.cs(15,13): error CS0246: The type or namespace name 'Configurablejoint' could not be found (are you missing a using directive or an assembly reference?)


    I have tried to look at the ConfigurableJoint documentation to figure out the namespace that I might need to include with a "using" statement, but I can't find anything and can't figure out, why the editor claims that the ConfigurableJoint namespace does not exist.

    I have attached my code below.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Events;
    5.  
    6. public class PhysicsButton : MonoBehaviour
    7. {
    8.  
    9.     [SerializeField] private fold thresholdcalue = .1f;
    10.     [SerializeField] private float deadZone = 0.025f;
    11.  
    12.     private bool isPressed;
    13.     private Vector startPos;
    14.     private Configurablejoint joint;
    15.  
    16.     public UnityEvent onPressed, onReleased;
    17.  
    18.     // Start is called before the first frame update
    19.     void Start()
    20.     {
    21.         startPos = transform.localPosition;
    22.         joint = GetComponent<Configurablejoint>();
    23.     }
    24.  
    25.     // Update is called once per frame
    26.     void Update()
    27.     {
    28.         if(!isPressed && GetValue() + threshold >= 1)
    29.             Pressed();
    30.         if(isPressed && GetValue() + threshold <= 0)
    31.             released();
    32.        
    33.     }
    34.  
    35.     private float GetValue(){
    36.         var value = Vector3.Distance(startPos, transform.localPosition) / joint.linearLimit.limit;
    37.         if(Math.Abs(value) < deadZone)
    38.             value = 0;
    39.  
    40.         return Mathf.Clamp(value, -1f, 1f);
    41.     }
    42.  
    43.     private void Pressed(){
    44.         isPressed = true;
    45.         onPressed.Invoke();
    46.         Debug.Log("Pressed");
    47.  
    48.     }
    49.  
    50.     private void Released(){
    51.         isPressed = false;
    52.         onPressed.Invoke();
    53.         Debug.Log("Released");
    54.     }
    55. }
    56.  
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
  3. lea_palucca

    lea_palucca

    Joined:
    Jun 16, 2022
    Posts:
    2
    Turns out I didn't even pay attention to case. Thanks for the help! :)
     
    MelvMay likes this.
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Hey, props to you for doing that... that's whatcha gotta do and you have put yourself in a good place, so just take it a little further next time. The error is (almost) always correct. For our humble purposes, we must treat the error as legit.

    In other news, as Melv pointed out, the IDE should be helping you. Here's notes on that:

    This may help you with intellisense and possibly other Visual Studio integration problems:

    Sometimes the fix is as simple as doing Assets -> Open C# Project from Unity. Other times it requires more.

    Other times it requires you also nuke the userprefs and .vsconfig and other crufty low-value high-hassle files that Visual Studio tends to slowly damage over time, then try the above trick.

    Barring all that, move on to other ideas:

    https://forum.unity.com/threads/intellisense-not-working-with-visual-studio-fix.836599/

    Also, try update the package inside of Unity: Window -> Package Manager -> Search for Visual Studio Editor -> Press the Update button

    Depending on flavor and version of Visual Studio, it may also have an installation step that you perform within the actual Visual Studio. This step seems finicky at best and may require multiple openings of VS before it comes up.

    Update: The VSCode extension has been deprecated and abandoned:

    https://forum.unity.com/threads/update-on-the-visual-studio-code-package.1302621/

    Update: the VSCode integration is back... maybe!?

    https://forum.unity.com/threads/microsoft-previews-unity-extension-for-visual-studio-code.1468913/

    There may be a community fork available that is receiving updates.

    https://github.com/Chizaruu/com.tsk.ide.vscode

    Also, this: https://forum.unity.com/threads/no-suggestions-in-vscode.955197/#post-6227874

    Recently (July 2023) I worked on a Windows11 system that required a Microsoft component to be installed from within Visual Studio before it would work properly with all the OTHER software installed under Unity. I have no documentation on that process as I have only seen it once and it surprised me as well.