- Home /
Help with AI script
Hello! I am receiving an error with my script. Any tips? I have tried adding 0,0); to the end already, and adding 0f,0f); to the end
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 = new Vector3 (transform.position + transform.forward*1f);
Error is here Instantiate(referenceToBulletPrefab, positionToShootFrom, Quaternion.Euler(Vector3.zero)); } // Update is called once per frame void Update () { } }
ERROR:
Assets/AIBullet.cs(14,34): error CS1729: The type UnityEngine.Vector3' does not contain a constructor that takes 1' arguments
Answer by imaginationrabbit · Jun 19, 2017 at 03:48 AM
Try removing "new Vector3 (transform.position + transform.forward*1f)"
and just use
Vector3 positionToShootFrom = transform.position + transform.forward;
I don't think you need to make a new Vector3 there and multiplying by 1f isn't doing anything.