- Home /
Question by
River-Ofarrows · May 20, 2016 at 03:49 AM ·
raycastsendmessageparameters
Racast hit (send message with parameters)
Hello I am trying to make a game with a lot destroyable things that the player will feal damage to by using a raycast hit which sends a message with the damage parameter but i keep getting this error:
NullReferenceException: Object reference not set to an instance of an object
here is my code in Js thanks in advance.
function Update () { if(Physics.Raycast(rayFrom, transform.forward, hit, 10)){ Swing(); } }
function Swing () { if (Input.GetButtonDown("Fire1")){ hit.collider.gameObject.SendMessage("applyDamage", damage); //this is the line with the problem } }
Comment
What the heck??? Why dosn't it show like it is supost to??