Ray-casting Problem
So I followed the instructions of a video - https://www.youtube.com/watch?v=6agwCUaMNWI
I followed the steps and entered this code in C# -
using UnityEngine; using System.Collections;
public class Raycastforward : MonoBehaviour {
// Update is called once per frame
void Update() {
RaycastHit hit;
float thedistance;
// Debug raycast in editor - So I can see it
Vector3 forward = transform.TransformDirection(Vector3.forward) = 10;
Debug.DrawRay(transform.position,forward,Color.green);
if(Physics.Raycast(transform.position,(forward), out hit)) {
thedistance = hit.distance;
print (thedistance + " " + hit.collider.gameObject.name);
}
}
}
And I got this error on the console -
Assets/Raycast.cs(12,37): error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer
How do I fix this? I'm new to unity started a few months ago. Any help is appreciated, thanks!
Your answer
Follow this Question
Related Questions
Raycasting through UI Image with transparent part 5 Answers
Select from multiple character to move 0 Answers
Problem making object keep on RaycastHit point relative to another object 0 Answers
How to make raycast ignore objects on layer based on distance to caster? 1 Answer
NullReferenceException on Raycast 0 Answers