I have a script I was intending to put on an empty game object in front of the enemy AI, however I am getting a lot of errors. These are the errors:
Assets/Meep/Scripts New/enemyshoottest.cs(16,71): error CS0019: Operator ‘*’ cannot be applied to operands of type ‘double’ and ‘UnityEngine.Vector3’
Assets/Meep/Scripts New/enemyshoottest.cs(16,26): error CS1502: The best overloaded method match for ‘UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion)’ has some invalid arguments
Assets/Meep/Scripts New/enemyshoottest.cs(16,26): error CS1503: Argument ‘#2’ cannot convert ‘object’ expression to type ‘UnityEngine.Vector3’
Assets/Meep/Scripts New/enemyshoottest.cs(20,52): error CS0119: Expression denotes a ‘type’, where a ‘variable’, ‘value’ or ‘method group’ was expected
Assets/Meep/Scripts New/enemyshoottest.cs(20,43): error CS1502: The best overloaded method match for ‘UnityEngine.Rigidbody2D.AddForce(UnityEngine.Vector2)’ has some invalid arguments
Assets/Meep/Scripts New/enemyshoottest.cs(20,43): error CS1503: Argument ‘#1’ cannot convert ‘object’ expression to type ‘UnityEngine.Vector2’
Assets/Meep/Scripts New/enemyshoottest.cs(25,60): error CS0119: Expression denotes a ‘type’, where a ‘variable’, ‘value’ or ‘method group’ was expected
Assets/Meep/Scripts New/enemyshoottest.cs(25,43): error CS1502: The best overloaded method match for ‘UnityEngine.Rigidbody2D.AddRelativeForce(UnityEngine.Vector2)’ has some invalid arguments
Assets/Meep/Scripts New/enemyshoottest.cs(25,43): error CS1503: Argument ‘#1’ cannot convert ‘object’ expression to type `UnityEngine.Vector2’
And here is my script:
using UnityEngine;
using System.Collections;
public class enemyshoottest : MonoBehaviour {
public Rigidbody2D clone;
public GameObject projectile;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
//attempt at bullet
//Rigidbody2D : clone;
clone = (Instantiate(projectile, transform.position+1.0*transform.forward,transform.rotation));
// Debug.Log(clone.transform.position + " : " + transform.position);
if(clone.transform.position.x < GameObject.FindWithTag("ariana").transform.position.x){
clone.transform.eulerAngles = new Vector3(0,0,180);
clone.rigidbody2D.AddForce(Vector2(-800,0));
}
else{
// Give the cloned object an initial velocity along the current
// object's Z axis
clone.rigidbody2D.AddRelativeForce(Vector2(800,0));
}
}
}