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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved The name "XRotation" does not exist in the current context

Discussion in 'Scripting' started by Aracksock, Oct 12, 2022.

  1. Aracksock

    Aracksock

    Joined:
    Oct 9, 2022
    Posts:
    2
    so recently ive gotten into coding and all of that and i have discovered a small problem, like the title says the name Xrotation apparently doesnt exist in the current context.

    Here is the code

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

    public class PlayerCam : MonoBehaviour
    {
    public float sensX;
    public float sensY;

    public Transform orientation;

    float xRotation;
    float yRotation;

    private void Start()
    {
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;
    }

    private void Update()
    {
    // get mouse input
    float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
    float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;

    yRotation += mouseX;

    XRotation -= mouseY;
    xRotation = Mathf.Clamp(xRotation, -90f, 90f);

    // rotate cam and orientation
    transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
    orientation.rotation = Quaternion.Euler(0, yRotation, 0);
    }
    }


    please help
     
  2. Aracksock

    Aracksock

    Joined:
    Oct 9, 2022
    Posts:
    2
    nevermind it got fixed after visual studios decided to save me
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,965
    When visual studios has these kinds of issues, 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 VSCode package inside of Unity: Window -> Package Manager -> Search for Visual Studio Code Editor -> Press the Update button

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