So I wrote this script based off of a script that was used in an answer on this website, but I have a problem: Unity says that public is unexpected and it was expecting the EOF. I’m not sure how to fix this since I’m rather new. This is a script for a shooting gun, and I need the projectile to be public, however the word “public” 1;1 is not recognized in the system. Please help, thank you!
public( Rigidbody )projectile;
public float speed = 20;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("Fire1"))
{
Rigidbody instantiatedProjectile = Instantiate(projectile,
transform.position,
transform.rotation)
as Rigidbody;
instantiatedProjectile.velocity = transform.TransformDirection(new Vector3(0, 0,speed));
}
}