hi, I have been getting this errors on my script and I don’t know how to get rid of them, can you help. I am new to c# so if they are easy to fix and a waste of time I am sorry!
Here are the errors:
Assets/Bullets.cs(27,25): error CS1502: The best overloaded method match for `UnityEngine.MonoBehaviour.StartCoroutine(string, object)’ has some invalid arguments
"Assets/Bullets.cs(27,25): error CS1503: Argument “#1” cannot convert “UnityEngine.GameObject” expression to type “string”
Here’s the script:
using UnityEngine;
using System.Collections;
public class Bullets : MonoBehaviour {
void Update (){
MakeBullet ();
}
void MakeBullet(){
if (Input.GetKey (KeyCode.Space)) {
Vector3 newPosition = new Vector3 ( 0, 0, 10);
GameObject Bullet = GameObject.CreatePrimitive (PrimitiveType.Cube);
Bullet.transform.position = new Vector3 (0, 0, 0);
Bullet.AddComponent<Rigidbody> ();
Bullet.GetComponent<Rigidbody> ().transform.localScale = new Vector3 (.05f, .05f, .1f);
Bullet.GetComponent<MeshRenderer> ().transform.localScale = new Vector3(.05f, .05f, .1f);
Bullet.GetComponent<BoxCollider> ().transform.localScale = new Vector3 (.05f, .05f, .1f);
StartCoroutine (Bullet, newPosition);
}
}
IEnumerator MoveFunction(GameObject obj, Vector3 newPosition)
{
float timeSinceStarted = 0f;
while (true)
{
timeSinceStarted += Time.deltaTime;
obj.transform.position = Vector3.Lerp(obj.transform.position, newPosition, timeSinceStarted);
if (obj.transform.position == newPosition)
{
yield break;
}
yield return null;
}
}
}