- var BulletSpawn : Transform;
- var Gun : Transform;
- var Bullet : GameObject;
- var Zombie : GameObject;
-
-
- function Start () {
-
- }
-
- function Update () {
- if(Input.GetButtonDown(“Fire1”)){
- Shoot();
- }
- Network.Instantiate(Bullet, BulletSpawn.transform.position, BulletSpawn.transform.rotation, 0);
- }
- function Shoot(){
- var hit: RaycastHit;
- if (Physics.Raycast(transform.position, transform.forward, hit)){
- if (hit.transform.tag == “Zombie”){
- Debug.Log(“Got a hit!”);
- Zombie = hit.transform.gameObject;
- Zombie.SendMessage(“TakeDamage()”, “Sniper”);
- }
- }
- }
That’s my code, and I do have the corrosponding “TakeDamage()” function call. Is it because my the sniper script (sending the message) is JS and my AI script is C#? (recieving the message). I’ve tried so many other things, but it doesn’t seem to work. I get the valid output from debug.log(“Got a hit!”);, but I can’t get the debug.log from the takedamage() function. Any help is greatly appreciated.