I'm trying to make a 2d platformer and I wrote up a script to make my main character spawn a projectile. I thought I had everything down but I got this error,"Assets/scripts/projectile.cs(27,24): error CS1061: Type `UnityEngine.Transform' does not contain a definition for `translate' and no extension method `translate' of type `UnityEngine.Transform' could be found." What does it mean exactly? here's the script for reference.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class projectile : MonoBehaviour {
public GameObject projectilePrefab;
private List projectiles = new List();
private float projectileVelocity;
// Use this for initialization
void Start () {
projectileVelocity = 3;
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown ("Jump")) {
GameObject bullet = (GameObject)Instantiate(projectilePrefab, transform.position, Quaternion.identity);
projectiles.Add(bullet);
}
for (int i = 0; i < projectiles.Count; i++) {
GameObject goBullet = projectiles [i];
if (goBullet != null) {
goBullet.transform.translate (new Vector3 (1, 0) * Time.deltaTime * projectileVelocity);
}
}
}
}
↧