Getting the error "ullReferenceException: Object reference not set to an instance of an object PlayerCasting.Update () (at Assets/Scripts/PlayerCasting.js:7) on my JavaScript raycasting script
I was trying to make a player raycasting script in JavaScript and I got the following error,
NullReferenceException: Object reference not set to an instance of an object PlayerCasting.Update () (at Assets/Scripts/PlayerCasting.js:7)
I cannot find any errors in my script (I am new to Unity and Coding in general) so it would be great if someone could help me resolve this error. Below is my script.
(/Saved Pictures/Capture.jpg "My Code"
Oops, never $$anonymous$$d. Looks like the image didn't work, haha.
Here is the code:
static var DistanceFromTarget : float;
var ToTarget : float;
function Update () { var Hit : RaycastHit; if (Physics.Raycast (transform.postion, transform.TransformDirection(Vector3.forward), Hit)) ToTarget = Hit.distance; DistanceFromTarget = ToTarget; }
Answer by QuantumGuardian · Jul 17, 2017 at 03:20 AM
Never mind, I fixed the error. It was a spelling error.
Your answer
Follow this Question
Related Questions
Forge-like in game editor 0 Answers
Unable to join player connection alternative multicast group. 1 Answer
Enoent error: diskusage.node not found when starting Unity Hub 0 Answers
how to not repeat random array 1 Answer
Having a OnTriggerEnter make another gameobject Add Force in UnityScript. 1 Answer