Hello,
I’m new to unity, and I’m trying to make something that looks like Space invaders. When the player presses the spacebar, I generate a cube, and then translate it updwards. What I’d like to do is, when I create the cube, which would be the bullet, create it on the same position as the player.
Here’s my code:
bullet = GameObject.CreatePrimitive(PrimitiveType.Cube);
bullet.AddComponent ('translateBullet');
and the translateBullet.js has:
function Start(){
var player = GameObject.FindWithTag('Player');
transform.position = player.transform.position;
transform.position = Vector3.up * 5;
transform.localScale.x = 20;
transform.localScale.y = 20;
transform.localScale.z = .1;
}
function Update () {
transform.Translate(Vector3.up * 1.5);
}