The strange thing is that opened scripts or newly opened ones are working fine. It's the new created C# scripts that are not working.
With not working, I mean the MonoBehaviour is not in light blue color it's in black color. In this screenshot I took, I marked it with a red circle.
What have I tried so far? I have closed Visual Studio and started over again. Since it didn't solve it, I closed the unity editor and started it over again, to no avail.
I pressed 'clean solution', I pressed 'rebuild solution', I pressed 'build solution'.
What else can I do ? And why are the other scripts working fine? If I type gameo...it will auto complete it to GameObject but in this specific script it's just not working.
This is a screenshot of the editor. I have in the Hierarchy a Ladder object. In the Assets I created a folder name Ladder and a script name Ladder. But this Ladder script is not working.
This is the Ladder script and this script was working before but once I created another script inside the ladder folder name Raise empty script the Raise script didn't work and now the Ladder is not working either. But other scripts are working fine.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Ladder : MonoBehaviour
{
public Transform charcontroller;
private bool inside = false;
private float heightFactor = 3.2f;
private void OnTriggerEnter(Collider other)
{
inside = true;
}
private void OnTriggerExit(Collider other)
{
inside = false;
}
private void Update()
{
if (inside == true && Input.GetKey("w"))
charcontroller.transform.position += Vector3.up / heightFactor;
}
}
No comments:
Post a Comment