Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Rotate bullet on 90 degrees

Discussion in 'Scripting' started by xarapuchatok, Jan 13, 2020.

  1. xarapuchatok

    xarapuchatok

    Joined:
    Dec 27, 2019
    Posts:
    11
    I have code on fire :
    Code (CSharp):
    1. void onFire()
    2. {
    3.     Vector3 SpawnPoint = flare.transform.position;
    4.     Quaternion SpawnRoot = flare.transform.rotation;
    5.     GameObject Bullet = Instantiate (bulletPrefab, SpawnPoint, SpawnRoot) as GameObject;
    6.     Rigidbody Run = Bullet.GetComponent<Rigidbody>();
    7.     Run.AddForce(Bullet.transform.forward * 2*Time.deltaTime, ForceMode.Impulse);
    8. }
    But bullet always position
    IIIIIII
    IIIIIII <---------- vertical
    IIIIIII
    IIIIIII
    And I need it must apeared in horizontal

    ````````````````` <---------------horizontal
    `````````````````
    How Can I do this?
     
  2. xarapuchatok

    xarapuchatok

    Joined:
    Dec 27, 2019
    Posts:
    11
    ok , I got it after that codehave to add one more line:
    Code (CSharp):
    1. Bullet.transform.eulerAngles = new Vector3(-90, Bullet.transform.eulerAngles.y, Bullet.transform.eulerAngles.z);