Hey. I get the error:
Assets \ touchcontrol.cs (10,14): error CS0103: The name ‘GameControl’ does not exist in the current context.
How do I resolve the error?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class touchcontrol : MonoBehaviour
{
// Start is called before the first frame update
private void OnMouseDown()
{
if (!GameControl.youWin)
transform.Rotate(0f, 0f, 90f);
}
}
Is GameControl another script in your project?
That script appears to be called “gamecontrol1” not “GameControl”.
Additionally, do you have a static variable on the script called “youWin”?
I changed the name of the script. But the problem unfortunately remained
Look at the name of your class in this screenshot. It is “gamecontrol1”. You need to change that too:
I agree. -This is a stupid mistake. Thanks PraetorBlue you helped me
hi i am new to unity and for some reason this code for wasd movement wont work (is it outdated?)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playermovement : MonoBehaviour
{
public CharacterController controller;
public float speed = 12f;
// Update is called once per frame
void Update()
{
float X = Input.GetAxis(“horizontal”);
float Z = Input.GetAxis(“Vertical”);
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(Move * speed * Time.deltaTime);
}
}
MelvMay
February 14, 2022, 4:28pm
10
Then please create your own threads rather than hijacking existing ones please. The same error doesn’t mean it’s the same bit of code to look at.
Also, please use code-tags when posting code and not plain text.
Thanks.
1 Like