Problem is not reproducible or outdated
How to fix (NullReferenceException: Object reference not set to an instance of an object) in my case
I have a bone projectile with this script attached to it. http://puu.sh/kyrsF/b8cc73ad12.png And in the main script attached to the player I instantiate the bone projectile to go the direction I want it to go. http://puu.sh/kyruL/a40e4c44da.png The problem is I get the NullReferenceException error and I have no idea how to fix it. Does anybody know any fix in my case?
What is a $$anonymous$$oveForward and how do you Instantiate it?
You'll have to tell us where and when and in what script the error is happening. The null reference exception is always due to a program$$anonymous$$g error - you forgot to assign an object, or you assumed that an object (for instance a component) would be there, when it isn't.
Just take a look at the error message, see what object is null when you're trying to access it, and you should have no trouble with fixing the error.
The error happens here in the main script ($$anonymous$$ovement) attached to the player: boneInstantiate.direction.x = $$anonymous$$athf.Cos(270 * $$anonymous$$athf.Deg2Rad);
The script attached to the bone projectile is called $$anonymous$$oveForward. So I am trying to change the value of the direction.x so I can affect which direction the bone projectile goes.
Does this actually work? Is far as I know you can instantiate a GameObject or Rigidbody but I dont see how your method would work.
I would add the script to the prefab and instantiate as a Rigidbody, or instantiate then add the script.
Follow this Question
Related Questions
Object reference not set to an instance of an object [HELP!] 0 Answers
JS NullReferenceException: Object reference not set to an instance of an object 1 Answer
Array of dictionaries: "Object reference not set to an instance of an object" 0 Answers
NullReferenceExeption when I use Mask 0 Answers
Unassigned Reference Exception although it is assigned 0 Answers