Hi everyone,
So I’m having a hell of a time trying to figure out whats going on in my game.
The script below seems to be somewhat working, only problem is i can’t select any of the Rigidbodies I have in my project folder.
When i go to the inspector to assign a Prefab to my projectile variable,
I get a list of no Assets and only one Scene Rigidbody (A small 3d character model).
I’m able to assign the Scene Rigidbody of the character model and fire it, but it’s obviously not what i’m looking to do.
I am certain there is a Rigidbody component in my projectile prefab as well as other prefabs, so this is really driving me up the wall.
Here’s the projectile script i’m using:
var projectile : Rigidbody;
var ammoCount = 100;
var initialSpeed = 20.0;
var fireSound : AudioClip;
function Fire(){
audio.PlayOneShot(fireSound);
ammoCount --;
var instantiatedProjectile : Rigidbody = Instantiate(projectile, transform.position, transform.rotation);
instantiatedProjectile.velocity = transform.forward * initialSpeed;
}
function NoAmmo(){}
function Update ()
{
if (Input.GetButtonDown("Fire1") && ammoCount != 0) {
Fire();
}
if (Input.GetButtonDown("Fire1") && ammoCount == 0){
NoAmmo();
}
}
Any help is greatly appreciated!
Thanks!