When i shoot with my gun, the bullet prefab spawn in the wrong direction, like in the image that i uploaded. No matter if i i change the direction of the prefab, when it spawns, it is in the wrong direction, making the bullet look like ridiculous! What i need to do so the bullet spawns in the right angle?
Here’s my shooting script:
using UnityEngine;
using System.Collections;
public class ShootDemo : MonoBehaviour
{
public Rigidbody projectile;
public float speed = 0;
// 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));
}
}
}