Hi,
I have a cube that is supposed to fire prefab cylinders which have a rigidbody. However, the cylinders are always coming out of the left side of the cube, instead of the front. I've tried changing the direction and using AddRelativeForce() but it will always come out of the left side.
Could someone explain to me why that is? Thanks.
void FixedUpdate () {
speed = Input.GetAxisRaw("Horizontal") * acceleration;
amountToMove = new Vector2(speed, 0);
transform.Translate(amountToMove * Time.deltaTime);
if(Input.GetButtonDown("Fire1")){
Debug.Log("Fire1 pressed!");
laser = Instantiate(laser, transform.position, transform.rotation) as GameObject;
laser.rigidbody.AddForce(laser.transform.forward * Time.deltaTime);
}
}
↧