Good morning all,
I hope everyone has reason to be excited for the weekend.
I will be trying to get this new highlighter script to work. The purpose of the script is to cause an object that is hit by a raycast generated from my player ( or his camera, rather ) to become highlighted by giving it a new shader. I have the shader and it works, okay, but I seem to be having a multitude of problems with the script. Not very familiar with C# , but I got a tutorial that uses it and a business acquaintance who swears by it. So, I was wondering if anyone would be willing to help out with this. I’m going to post what I have and the errors I am receiving and perhaps someone could find it in their heart to point out where I’m screwing up. Thank you for your time this morning.
so here’s the script so far…
using UnityEngine;
using System.Collections;
public class PlayerInteractionScript : MonoBehaviour {
private Transform myCam;
private GameObject viewing;
private Shader holdShader;
public float rayCastDistance = 3.0f;
public Shader highlightShader;
// Use this for initialization
void Start () {
myCam = GetComponentInChildren().transform;
Screen.lockCursor = true;
}
// Update is called once per frame
void Update () {
if (viewing != null) {
if (viewing.tag == “HotSpot”) {
//unhighlight hotspot
}
}
viewing = LookingAt();
if (viewing != null) {
//highlight hotspot
}
}
}
GameObject LookingAt () {
Ray ray = new Ray(myCam.position, myCam.forward);
RaycastHit hit = new RaycastHit();
if (Physics.Raycast (ray, out hit, rayCastDistance)) {
return hit.transform.gameObject;
} else {
return null;
}
}
}
and here are the errors I am getting
“Assets/Highlighter.cs(43,1): error CS8025: Parsing error”
“Assets/Highlighter.cs(34,12): error CS0116: A namespace can only contain types and namespace declarations”
I have highlighted in RED the lines involving the errors. Hope that helps.
Thanks
-Richard