The first tutorial’s script (for scripting) doesn’t work.
What version should I be using?
The first tutorial’s script (for scripting) doesn’t work.
What version should I be using?
Which tutorial is this?
Is it the one introducing you to what scripts are with the example of changing a game object’s colour?
Yup
Perhaps try something like this for 5.xx
using UnityEngine;
using System.Collections;
public class ChangeColor : MonoBehaviour
{
private Renderer m_Renderer;
void Start()
{
m_Renderer = gameObject.GetComponent<Renderer>();
}
void Update()
{
if(Input.GetKeyDown(KeyCode.R)) {
m_Renderer.material.color = Color.red;
}
if(Input.GetKeyDown(KeyCode.G)) {
m_Renderer.material.color = Color.green;
}
if(Input.GetKeyDown(KeyCode.B)) {
m_Renderer.material.color = Color.blue;
}
}
}
Still doesnt work, but why not? It really has no reasons when I try to debug it
How does this differ from yours ??
added:
Tried to add a zip file of my project … but failed …
I’m not entirely sure, after trying it in 4.6 and 5 I can’t make it not work. Is the script definitely attached to the game object?
Yup, as a component
I’m unsure as to what’s happening without seeing it. Could you share your code, or even the project you’re doing it in?
Ensure that your class name is the same as the Script name … exactly the same.
Ive checked the class names and Script name, both exactly the same.
Eyoo! Just did some checkups, found that the script wasn’t attached because I made another script on top of it (something like that). It works now, thanks for all the help!
Good to hear, good luck in your learning c: