Question by
guitarxe · Mar 29, 2016 at 05:03 PM ·
instantiatetransformtranslate
Transform.up does not work after instantiating object
Have bullet with this script:
public class BulletMoveScript : MonoBehaviour
{
public float speed;
public float duration;
void Awake()
{
Destroy(gameObject, duration);
}
void Update()
{
transform.Translate(transform.up * Time.deltaTime * speed);
}
}
Have gun that fires bullet:
Instantiate(projectile, bulletSpawnPos.transform.position, Quaternion.Euler(direction)
"direction" is either left (0, 0, -90) or right (0, 0, 90).
However after instantiation the bullet does not translate along the "up", i.e "green" axis any longer, it just goes along some random vector. How come? It works correctly if the bullet is just dropped into the scene and let fly. The issue only happens if it is instantiated.
Comment