Hello again.

I made a few scripts in my flight sim so my aircraft shoots projectiles, but i can’t figure out a way to make it instantiate in the angle that i want.

Projectile Script:

using UnityEngine;
using System.Collections;

public class Projectile : MonoBehaviour {
	
	public float speed = 60.0f;

	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{

		transform.Translate(new Vector3(0.0f, 0.0f ,speed*Time.deltaTime ));
	}
}

Script that spawns the Projectile:

using UnityEngine;
using System.Collections;

public class shipshoot : MonoBehaviour {
	public GameObject playerProjectile;
	public Transform Source;
	public float TimeBetweenShots = 0.2f;
	
	private float _NextSHot = 0.0f;
	
	// Use this for initialization
	void Start () {
		
		Source = transform;
	
	}
	
	// Update is called once per frame
	void Update () {
		
		if (Input.GetMouseButton(0) && Time.time > _NextSHot)
		{
			_NextSHot = Time.time + TimeBetweenShots;
			Instantiate(playerProjectile, Source.position, Source.rotation);
		
		}
}
}

The result of everything above is this:
alt text

But i want the projectile to come out like this:
alt text

Any ideas?

The easiest way to fix this problem is to create an empty game object, make the capsule a child of the empty game object and then apply a rotation to the visible object. Scripts go on the empty game object.

You can also calculate the rotation. You said ‘capsule’ so I’m assuming you want the ‘y’ of the capsule to point forward. And I’m assuming you are firing out the front (side facing positive ‘z’ when the ship has no rotaiton). Put these three lines in place of line 24:

GameObject go = Instantiate(playerProjectile, Source.position, Quaternion.identity) as GameObject;
Quaternion q = Quaternion.FromToRotation(Vector3.up, transform.forward);
go.transform.rotation = q * go.transform.rotation;