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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Space Shooter

Discussion in 'Scripting' started by Vampyr_Engel, Mar 19, 2017.

  1. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Yes I would like to convert that level of the Space Shooter tutorial to turn it into 3d but I need to know how I could make the space ship and the Asteriods and the Alien Ships to urn in 3d upwards and downwards to chase the player and the player to avoid and to chase as well How do I get it to turn in 3d ?
     
    Last edited: Mar 19, 2017
  2. mumbot

    mumbot

    Joined:
    Oct 19, 2012
    Posts:
    86
    It's the same concept except your working with another axis 'Z'. The simplest way would be to do a transform.lookat and make the ship look at input.mousePosition. as for the asteroids spawning them is the same but with the Z axis.
    Code (CSharp):
    1. new Vector3(Random.Range(-200,200),Random.Range(-200,200) ,Random.Range(-200,200) )
     
  3. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    And this would work for the A,I Ships and Asteriods as well?
     
  4. mumbot

    mumbot

    Joined:
    Oct 19, 2012
    Posts:
    86
    yes the transform.lookat function will work how ever there is no delay in there rotation and they will always be facing what ever transform you pass through the function.
     
  5. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK thanks