when i shoot the bullets go in the right direction but at the wrong angle
heres my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Gun : MonoBehaviour
{
public Transform bulletSpawnPoint;
public GameObject bulletPrefab;
public float bulletSpeed = 10;
public Vector2 turn;
private void Update()
{
turn.x += Input.GetAxis("Mouse X");
turn.y += Input.GetAxis("Mouse Y");
if(Input.GetMouseButtonDown(0))
{
var bullet = Instantiate(bulletPrefab, bulletSpawnPoint.position, bulletSpawnPoint.rotation);
bullet.GetComponent<Rigidbody>().velocity = bulletSpawnPoint.forward * bulletSpeed;
}
}
}
yes that's right already, the bullets go where I want them to go but they are going facing down, I wanted to know if there was a way to rotate the prefab or something like that
– eduardogrutThe third parameter (
– unity_I8FaTX-tZFc4lAbulletSpawnPoint.rotation) of the Instantiate function is the rotation of the bullet when it is instantiated.