Question by
mugiwara23 · May 08, 2018 at 04:58 PM ·
shootershotshotgun
Shooting script,I can shot in Y axis ,
Hello , i'm doing my first shooter game , but when I use my script I can't shot in the Y.-Y axis(up and down) the bullets are not following my direction, any information can help to solve it.
using UnityEngine; using System.Collections;
public class Disparos : MonoBehaviour {
public GameObject balaOriginal;
public float vel;
public GameObject puntoSpawn;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
//Che input
if (Input.GetKeyDown(KeyCode.Mouse0))
{
//Disparar
LanzarProyectil();
}
}
void LanzarProyectil()
{ //obtener referenia del clon recien creado
GameObject nuevaBala;
nuevaBala = (GameObject)Instantiate(balaOriginal,puntoSpawn.transform.position,this.transform.rotation);
//Objeter la referencia de su Rigibody
Rigidbody rigidDelClon;
rigidDelClon = nuevaBala.GetComponent<Rigidbody>();
//Dar velocidad
rigidDelClon.velocity = transform.forward * vel;
}
},Hello , I'm doing my first shooter game, I make this fo shooting but I can't shot in Y and -Y axis, (up and dow ), if I shot in other directions it follows correctly.
using UnityEngine; using System.Collections;
public class Disparos : MonoBehaviour {
public GameObject balaOriginal;
public float vel;
public GameObject puntoSpawn;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
//Che input
if (Input.GetKeyDown(KeyCode.Mouse0))
{
//Shot
LanzarProyectil();
}
}
void LanzarProyectil()
{ //Clon Ref
GameObject nuevaBala;
nuevaBala = (GameObject)Instantiate(balaOriginal,puntoSpawn.transform.position,this.transform.rotation);
//Rigibody Ref
Rigidbody rigidDelClon;
rigidDelClon = nuevaBala.GetComponent<Rigidbody>();
//Give Speed . rigidDelClon.velocity = transform.forward * vel;
}
}
Comment