I am using the following script to “shoot” a bullet.
var shotsound:AudioClip;
var shellPrefab : GameObject;
var proyectilevelocity:int;
var ammo:int;
var fireRate = 1.0;
private var nextfire = 0.0;
function FixedUpdate () {
if(Input.GetButton("Jump") Time.time>nextfire ammo>0)
ShotProyectile();
}
function ShotProyectile(){
if(Time.time > nextfire)
{
var Grenade:GameObject = Instantiate(shellPrefab,transform.position,transform.rotation);
Grenade.GetComponentInChildren(Rigidbody).velocity =transform.TransformDirection(Vector3(0,0,proyectilevelocity));
ammo--;
if(shotsound)
audio.PlayOneShot(shotsound);
Destroy(Grenade,10);
nextfire = Time.time+fireRate;}
}
This shoots the bullet straight out. How do I change the script to send the bullet out like a 45 deg angle up so it lobs the bullet? I assume transform.rotation needs to change but I don’t know what I need to do.
Can anyone help?