Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing some code in JavaScript for a ray cast shooting program. I have all the variables I need except for sound, and I'm not too sure on how to add that variable into my code. I would really appreciate any help people can give to solve this problem, and show me how to add a sound variable to my code.

#pragma strict

var Effect : Transform;
var Damage = 100;

function Update () {

	var hit : RaycastHit;
	var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0)); 
	
	if (Input.GetMouseButtonDown(0))
	{
		if (Physics.Raycast (ray, hit, 100))
		{
			hit.transform.SendMessage("ApplyDamage", Damage, SendMessageOptions.DontRequireReceiver);
		}
	}
}

share|improve this question
1  
Look here. – Exerion Oct 24 '15 at 8:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.