Rotating Instantiated Prefab (Projectile)

Hi, first time posting! I scoured google and unity answers but I still can’t seem to solve the issue of instantiating a prefab with the original rotations on the y and z axis.

The original prefab has the rotations of (0, 90, 90) but the clones are being instantiated with the rotation of (0, 0, 0).

Here’s the code for how I’m instantiating the prefab:

 public void ReleaseAndShoot(float shotForce)
    {
        draw = false;
        currentProjectile.transform.parent = null;
        Rigidbody projectileRigidBody = currentProjectile.GetComponent<Rigidbody>();
        projectileRigidBody.isKinematic = false;
        projectileRigidBody.AddForce(transform.forward * shotForce, ForceMode.Impulse);
        slingshotString.CenterPoint = DrawFrom;
        if (ammoCount > 0)
        {
            ammoCount--;
            txt.text = ammoCount + "";
        }
    }

    public void DrawSlingShot(float speed)
    {
        draw = true;
        currentProjectile = Instantiate(Projectile, DrawFrom.position, Quaternion.Euler(0,90,90), transform);
        currentProjectile.forward = transform.forward;
        slingshotString.CenterPoint = currentProjectile.transform;

        float waitTimeBetweenDraws = speed / NrDrawIncrements;
        StartCoroutine(drawSlingShotWithIncrements(waitTimeBetweenDraws));
    }

    private IEnumerator drawSlingShotWithIncrements(float waitTimeBetweenDraws)
    {
        for (int i = 0; i < NrDrawIncrements; i++)
        {
            if (draw)
            {
                currentProjectile.transform.position = Vector3.Lerp(DrawFrom.position, DrawTo.position, (float)i / NrDrawIncrements);
                yield return new WaitForSeconds(waitTimeBetweenDraws);
            }
            else
            {
                i = NrDrawIncrements;
            }
        }
    }

You can see where I’m trying to instantiate the prefab with the correct rotation:

 currentProjectile = Instantiate(Projectile, DrawFrom.position, Quaternion.Euler(0,90,90), transform);
        currentProjectile.forward = transform.forward;
        slingshotString.CenterPoint = currentProjectile.transform;

by using Quaternion.Euler(0,90,90)

Any help on this is appreciated! Only been coding for 2 months so please have mercy! Thanks.

Hello.

ypu can try to rotate it right afer instantiating.

Whem instantiate something, you can access it like this:

GameObject newProjectile = Instantiate(projectileprefab);

newProjectile.transform.rotation = something;
newProjectile.transform.position = something;
newProjectile.transform.parent = something;

Buee!

If the prefab already has the rotation set, you can try:

currentProjectile = Instantiate(Projectile, DrawFrom.position, Quaternion.Identity, transform);

or

currentProjectile = Instantiate(Projectile, DrawFrom.position);
currentProjectile.transform.SetParent(transform);

(less performant I think)

Also Check: [this other question][1]

If you want to rotate it later on, you can do it through the RigidBody: ([see RigidBody.MoveRotation][2])

If none of this works, maybe the problem resides on your Prefab setup.
At least this is how I do it ^_^u