have a problem,I shoot only around me. GEAR VR OCULUS

I have this code for shoot for gear:

var proyectil : Rigidbody;
//var sonidoDisparo : AudioClip;
var velocidadProyectil :float = 40.0;
function Update () {
if (Input.GetButtonDown (“Fire1”)) {
var bala : Rigidbody = Instantiate (proyectil, transform.position, transform.rotation);
bala.velocity = transform.TransformDirection(Vector3 (0,0,velocidadProyectil));
bala.name = “proyectil”;
// Physics.IgnoreCollision(bala.collider, transform.root.collider);
// audio.PlayOneShot(sonidoDisparo);
}
}

I made a cilinder, after a gameObject to shoot and created my bullet.

Only can shoot forward in the vector3

Someone how to know shoot in all directions when you look?
example when you look to your sky

:(:(:(:(:(:(:(:(:(:(:frowning:

thanks for your read:eyes:

Hi everybody.

Could I use vuforia or raycast to help me asked?

:hushed:

regards

I’ve not tested it myself but perhaps try changing your vector along the z axis to Camera.main.transform.forward instead. That should use whichever direction you camera is facing including the sky! :slight_smile:

1 Like

What Neil said above should work.

What is happening depends on what your script is attached to (because “transform” refers to the parent/GameObject containing the script)

Is this script attached to the Camera? Or is it attached to the cylinder?

If script is attached to camera, I believe your rigidbody instantiation would automatically match your camera view and might work okay as written. (I’d have to test it out)

But if the script is attached to another object, you will need to make a call to Camera’s forward vector as mentioned above…

Thanks for the answer, but my english is low and few people can`t understand me.

Now this issue is resolved by other thread in unity. Thanks guru20

and NeilC_VP thanks for the answer and regards

If anybody need information about shoot all the points where you looked.
Send me private messages.