- Home /
Question by
KingSloth · Jun 16, 2017 at 01:15 AM ·
c#scripting problemerrorerror message
Help with basic AI script
Hello! I am receiving an error with my script. Any tips?
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);
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
Comment
Answer by Michcan · Jun 16, 2017 at 02:03 AM
thats because Vector3 takes 3 arguments pos X pos Y and pos Z
if you dont want the bullet to move other than in X ex: new Vector3(transform.position.x + transform.right * 1f,0,0);
the zeros represent y and z
It gives me an error that says that the expression denotes "type", where a variable or group should be. What should I do?