Tryed to make laser bolt-shooting gun like in “Space Shooter” tutorial but for 3d.
Made two scripts. First for instantiating:
Instantiate (Shot,ShotSpawn.position,ShotSpawn.rotation);
Where Shot is my bolt prefab, ShotSpawn is empty gameobject on my gun.
Second for bolt movement:
void Start()
{
GetComponent<Rigidbody> ().velocity = transform.forward * Speed;
Destroy (gameObject, DestroyOn);
}
The result is that bolt always facing toward z axis (forward). I want to make it relative to my ship’s angle (ShotSpawn’s direction). Any ideas?