Hello! I just need help with my Enemies. The bullet only facing a certain direction. I made an empty game object, and added the script to it. I put the game object as a child to the enemy. No matter how much I rotate the Fire Point, the bullet won' t move. Any Help is appreciated. Here is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AIBullet : MonoBehaviour {
public GameObject referenceToBulletPrefab;
public float timeToWaitBetweenShots;
void Start(){
InvokeRepeating("ShootBullet", timeToWaitBetweenShots, timeToWaitBetweenShots);
}
void ShootBullet(){
Vector3 positionToShootFrom = transform.position + transform.forward;
Instantiate(referenceToBulletPrefab, positionToShootFrom, Quaternion.Euler(Vector3.zero));
}
// Update is called once per frame
void Update () {
}
}
↧