Failed to call function WeaponFire of class gunScript
Calling function WeaponFire with no parameters but the function requires 1.
UnityEngine.Component:SendMessage(String)
weaponController:Update() (at Assets/Fps scripts/weaponController.cs:12)
Here’s the script :
GunScript :
using UnityEngine;
using System.Collections;
//This script instantiates a bullet.
public class gunScript : MonoBehaviour
{
public Transform bullet;
//Called by playerStatus script
//Instantiates a bullet which is passed in the arguments from PlayerStatus
void WeaponFire(Transform bullet)
{
Instantiate(bullet, transform.position, transform.rotation);
}
}
WeaponControllerScript :
using UnityEngine;
public class weaponController : MonoBehaviour
{
public Transform weapon;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("1"))
{
weapon.SendMessage("WeaponFire");
}
}
}
I cant make the gun fire the bullets (the bullets wont spawn).