Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Tutorial Project: Stealth under Unity 5.x

Discussion in 'Community Learning & Teaching' started by Vagabond820, Mar 10, 2015.

  1. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    Video 6 - Game Controller

    Here too, the script needs an update and the API upgrade tool is offering it:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class LastPlayerSighting : MonoBehaviour
    5. {
    6.     public Vector3 position = new Vector3 (1000f, 1000f, 1000f);
    7.     public Vector3 resetPosition = new Vector3 (1000f, 1000f, 1000f);
    8.     public float lightHighIntensity = 0.25f;
    9.     public float lightLowIntensity = 0f;
    10.     public float fadeSpeed = 7f;
    11.     public float musicFadeSpeed = 1f;
    12.  
    13.     private AlarmLight alarm;
    14.     private Light mainLight;
    15.     private AudioSource panicAudio;
    16.     private AudioSource[] sirens;
    17.  
    18.     void Awake ()
    19.     {
    20.         alarm = GameObject.FindGameObjectWithTag (Tags.alarm).GetComponent<AlarmLight> ();
    21.         mainLight = GameObject.FindGameObjectWithTag (Tags.mainLight).light;
    22.         panicAudio = transform.Find ("secondaryMusic").audio;
    23.         GameObject[] sirenGameObjects = GameObject.FindGameObjectsWithTag (Tags.siren);
    24.         sirens = new AudioSource[sirenGameObjects.Length];
    25.  
    26.         for (int i =0; i < sirens.Length; i++)
    27.         {
    28.             sirens [i] = sirenGameObjects [i].audio;
    29.         }
    30.     }
    31.  
    32.     void Update ()
    33.     {
    34.         SwitchAlarms ();
    35.         MusicFading ();
    36.     }
    37.  
    38.     void SwitchAlarms ()
    39.     {
    40.         alarm.alarmOn = (position != resetPosition);
    41.  
    42.         float newIntensity;
    43.  
    44.         if (position != resetPosition)
    45.         {
    46.             newIntensity = lightLowIntensity;
    47.         }
    48.         else
    49.         {
    50.             newIntensity = lightHighIntensity;
    51.         }
    52.  
    53.         mainLight.intensity = Mathf.Lerp (mainLight.intensity, newIntensity, fadeSpeed * Time.deltaTime);
    54.  
    55.         for (int i = 0; i < sirens.Length; i++)
    56.         {
    57.             if (position != resetPosition && !sirens [i].isPlaying)
    58.             {
    59.                 sirens [i].Play ();
    60.             }
    61.             else if (position == resetPosition)
    62.             {
    63.                 sirens [i].Stop ();
    64.             }
    65.         }
    66.     }
    67.  
    68.     void MusicFading ()
    69.     {
    70.         if (position != resetPosition)
    71.         {
    72.             audio.volume = Mathf.Lerp (audio.volume, 0f, musicFadeSpeed * Time.deltaTime);
    73.             panicAudio.volume = Mathf.Lerp (panicAudio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
    74.         }
    75.         else
    76.         {
    77.             audio.volume = Mathf.Lerp (audio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
    78.             panicAudio.volume = Mathf.Lerp (panicAudio.volume, 0f, musicFadeSpeed * Time.deltaTime);
    79.         }
    80.     }
    81. }

    Click on "I Made a Backup. Go Ahead!" in the "API Update required" window so that the editor updates the script to the current syntax.

    Note: the "API Update required" window will not open if you have errors in the console. You'll have to fix these errors before it does and you can update the script.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class LastPlayerSighting : MonoBehaviour
    5. {
    6.     public Vector3 position = new Vector3 (1000f, 1000f, 1000f);
    7.     public Vector3 resetPosition = new Vector3 (1000f, 1000f, 1000f);
    8.     public float lightHighIntensity = 0.25f;
    9.     public float lightLowIntensity = 0f;
    10.     public float fadeSpeed = 7f;
    11.     public float musicFadeSpeed = 1f;
    12.  
    13.     private AlarmLight alarm;
    14.     private Light mainLight;
    15.     private AudioSource panicAudio;
    16.     private AudioSource[] sirens;
    17.  
    18.     void Awake ()
    19.     {
    20.         alarm = GameObject.FindGameObjectWithTag (Tags.alarm).GetComponent<AlarmLight> ();
    21.         mainLight = GameObject.FindGameObjectWithTag (Tags.mainLight).GetComponent<Light>();
    22.         panicAudio = transform.Find ("secondaryMusic").GetComponent<AudioSource>();
    23.         GameObject[] sirenGameObjects = GameObject.FindGameObjectsWithTag (Tags.siren);
    24.         sirens = new AudioSource[sirenGameObjects.Length];
    25.  
    26.         for (int i =0; i < sirens.Length; i++)
    27.         {
    28.             sirens [i] = sirenGameObjects [i].GetComponent<AudioSource>();
    29.         }
    30.     }
    31.  
    32.     void Update ()
    33.     {
    34.         SwitchAlarms ();
    35.         MusicFading ();
    36.     }
    37.  
    38.     void SwitchAlarms ()
    39.     {
    40.         alarm.alarmOn = (position != resetPosition);
    41.  
    42.         float newIntensity;
    43.  
    44.         if (position != resetPosition)
    45.         {
    46.             newIntensity = lightLowIntensity;
    47.         }
    48.         else
    49.         {
    50.             newIntensity = lightHighIntensity;
    51.         }
    52.  
    53.         mainLight.intensity = Mathf.Lerp (mainLight.intensity, newIntensity, fadeSpeed * Time.deltaTime);
    54.  
    55.         for (int i = 0; i < sirens.Length; i++)
    56.         {
    57.             if (position != resetPosition && !sirens [i].isPlaying)
    58.             {
    59.                 sirens [i].Play ();
    60.             }
    61.             else if (position == resetPosition)
    62.             {
    63.                 sirens [i].Stop ();
    64.             }
    65.         }
    66.     }
    67.  
    68.     void MusicFading ()
    69.     {
    70.         if (position != resetPosition)
    71.         {
    72.             GetComponent<AudioSource>().volume = Mathf.Lerp (GetComponent<AudioSource>().volume, 0f, musicFadeSpeed * Time.deltaTime);
    73.             panicAudio.volume = Mathf.Lerp (panicAudio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
    74.         }
    75.         else
    76.         {
    77.             GetComponent<AudioSource>().volume = Mathf.Lerp (GetComponent<AudioSource>().volume, 0.8f, musicFadeSpeed * Time.deltaTime);
    78.             panicAudio.volume = Mathf.Lerp (panicAudio.volume, 0f, musicFadeSpeed * Time.deltaTime);
    79.         }
    80.     }
    81. }

    Working like a charm! ;)
     
  2. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    Video 7 - CCTV Cameras

    Making animations in Unity 5 is fairly different:
    • creating the CCTVSweep animation in unchanged,
    • adding the CCTVSweep animation to the prop_cctvCam_joint creates an "Animator" instead of an "Animation":
    Video07_Anim.JPG

    Nothing to worry about; although different, the Animation view is still there:
    • with "prop_cctvCam_joint" selected in the hierarchy window, go to Window and open the "Animation" window. On doing this I got an error:
    Video07_Anim01.JPG

    that I fixed by deleting the faulty property and creating a new one:

    Video07_Anim02.jpg
    • once the new property has been created, select "Curves" at the bottom of the window. With "Rotation y" selected, grab the key frame that already exists at 1:00 and drag it to 2:00. Once this done, set it to "60":
    Video07_Anim03a.jpg
    • to make the animation loop, select "CCTVSweep" in the Project view, and check "loop time".
    On testing, it appears that the animation doesn't behave as smoothly as in the video; the camera rotates to the left by 60 ° and comes immediately back to 0, instead of playing backwards. The only solution I've found is adding a second key frame at 4:00 and setting "Rotation y" to 0:

    Video07_Anim03.jpg

    Now it runs as intended. Why it stops at 0 instead of going to the right, I don't know. :)

    Addenda:

    Instead of adding a second key frame at 4:00, we can slightly modify the controller that has been created for this animation, its state machine. To do that:
    • first delete the key frame at 4:00,
    • then go to Window/Animator,
    • focus the scene view on the camera and play the game,
    • in the Animator view, select the orange state and use Ctrl+d to duplicate it,
    • select the duplicated state, move it so that it doesn't overlap the original state, and, in the Inspector, set "speed" to -1,
    • right click on the orange state, select "make transition", drag the wire to the duplicated state and click,
    • select the duplicate state, make a transition and drag the wire to the orange state.
    Since you are in play mode, you should see both states playing one after another and the camera should move smoothly to the left and back to its original position. Quit the play mode and save.
     
    Last edited: Jul 3, 2016
    BerniceChua likes this.
  3. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    Video 8 - Laser Grids:

    Found a mistake in the Laser Switch Deactivation script: the LaserDeactivation function is set to access the parent object ("prop_switchUnit_screen_001") renderer instead of the child object renderer ("prop_switchUnit_screen").

    Once fixed, the script reads:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class LaserSwitchDeactivation : MonoBehaviour
    5. {
    6.     public GameObject laser;
    7.     public Material unlockedMat;
    8.  
    9.     private GameObject player;
    10.     private Renderer screenRend;
    11.  
    12.     void Awake ()
    13.     {
    14.         player = GameObject.FindGameObjectWithTag (Tags.player);
    15.     }
    16.  
    17.     void OnTriggerStay (Collider other)
    18.     {
    19.         if (other.gameObject == player)
    20.         {
    21.             if (Input.GetButton ("Switch"))
    22.             {
    23.                 LaserDeactivation ();
    24.             }
    25.         }
    26.     }
    27.  
    28.     void LaserDeactivation ()
    29.     {
    30.         laser.SetActive (false);
    31.         screenRend = transform.Find ("prop_switchUnit_screen").GetComponent<Renderer>();    //instead of ("prop_switchUnit_screen_001")
    32.  
    33.         screenRend.material = unlockedMat;
    34.         GetComponent<AudioSource>().Play ();
    35.     }
    36. }

    Tested and working. ;)
     
    Last edited: Jul 16, 2016
  4. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    Session 2, Video 2, Player Animator Controller:

    I've had a silly little problem with the "Sneak" animation. Once the animator controller finished, it happened that the player could enter sneak position, his feet moved but he didn't move forward, back, or sidewise. Modifying the speed made it work but it made the whole thing ridiculous, with the player's feet moving frantically! Yuk!

    The only thing that could make the motion work perfectly was removing the collider, or setting it "trigger". I was about to renounce when I had an idea: I replaced the ordinary capsule collider by a "Character Controller" and kept the Rigidbody. Now the animator controller works fine!

    The Character Controller triggers the alarms as well as the capsule collider did.
     
  5. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    Now, since I didn't use the GUITexture mentioned in the video, but created an animation, I now need to create the second state of the state machine.
    • With "ScreenFader" selected in the hierarchy view, going to Window and clicking on "Animator".
    • In the view, I select the orange state (the starting state, that doesn't need a script to play) and rename it "ScreenFadeOutClip".
    • Then I duplicate it and rename the duplicate into "ScreenFadeInClip".
    • With this state selected, going to the inspector view and change its speed to -1.
    • After that, selecting the orange "ScreenFadeOutClip", right click on it and make a transition to the duplicate "ScreenFadeInClip".
    • On the left in the Animator window, click on the "Parameters" tab and create a trigger that I named "GameOver".
    • Lastly, clicking on the transition I made from the "ScreenFadeOutClip" to the "ScreenFadeInClip", and, in the Inspector view, scrolling down to "Conditions" and add "GameOver".
    After, doing all this, I've made my own "SceneFadeInOut" script that I added to the ScreenFader in the hierarchy window (this new script doesn't require making any changes to the PlayerHealth script):

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.SceneManagement;
    4.  
    5. public class SceneFadeInOut : MonoBehaviour
    6. {
    7.     private Animator anim;
    8.     private float restartTimer;
    9.     private float restartDelay = 2.5f;
    10.  
    11.     void Awake ()
    12.     {
    13.         anim = GetComponent<Animator> ();
    14.     }
    15.  
    16.     public void EndScene ()
    17.     {
    18.         anim.SetTrigger ("GameOver");
    19.         restartTimer += Time.deltaTime;
    20.         RestartLevel ();
    21.     }
    22.  
    23.     void RestartLevel ()
    24.     {
    25.         if (restartTimer >= restartDelay)
    26.         {
    27.             SceneManager.LoadScene ("Stealth");
    28.         }
    29.     }
    30. }

    Actually, this is my first script!
     
    Last edited: Jul 11, 2016
  6. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    Cleaning scripts:

    Before carrying on, I feel the need to clean the scripts. The scripts have been updated by the API Updater so that they work but they make repetitive use of "GetComponent<xxx> ();" instead of caching the values, probably slowing down the process, and/or have obsolete content.

    Cleaned versions:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class AlarmLight : MonoBehaviour
    5. {
    6.     public float fadeSpeed = 2f;
    7.     public float highIntensity = 2f;
    8.     public float lowIntensity = 0.5f;
    9.     public float changeMargin = 0.2f;
    10.     public bool alarmOn;
    11.  
    12.     private Light redLight;               //give it any name except "light"
    13.     private float targetIntensity;
    14.  
    15.     void Awake ()
    16.     {
    17.         redLight = GetComponent<Light> ();
    18.  
    19.         redLight.intensity = 0f;
    20.         targetIntensity = highIntensity;
    21.     }
    22.  
    23.     void Update ()
    24.     {
    25.         if (alarmOn)
    26.         {
    27.             redLight.intensity = Mathf.Lerp (redLight.intensity, targetIntensity, fadeSpeed * Time.deltaTime);
    28.             CheckTargetIntensity ();
    29.         }
    30.         else
    31.         {
    32.             redLight.intensity = Mathf.Lerp (redLight.intensity, 0f, fadeSpeed * Time.deltaTime);
    33.         }
    34.     }
    35.  
    36.     void CheckTargetIntensity ()
    37.     {
    38.         if (Mathf.Abs (targetIntensity - redLight.intensity) < changeMargin)
    39.         {
    40.             if (targetIntensity == highIntensity)
    41.             {
    42.                 targetIntensity = lowIntensity;
    43.             }
    44.             else
    45.             {
    46.                 targetIntensity = highIntensity;
    47.             }
    48.         }
    49.     }
    50. }

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerHealth : MonoBehaviour
    5. {
    6.     public float health = 100f;
    7.     public float resetAfterDeathTime = 5f;
    8.     public AudioClip deathClip;
    9.  
    10.     private Animator anim;
    11.     private PlayerMovement playerMovement;
    12.     private HashIDs hash;
    13.     private SceneFadeIn sceneFadeIn;
    14.     private LastPlayerSighting lastPlayerSighting;
    15.     private float timer;
    16.     private bool playerDead;
    17.  
    18.     void Awake ()
    19.     {
    20.         anim = GetComponent<Animator> ();
    21.         playerMovement = GetComponent<PlayerMovement> ();
    22.         hash = GameObject.FindGameObjectWithTag (Tags.gameController).GetComponent<HashIDs> ();
    23.         sceneFadeIn = GameObject.FindGameObjectWithTag (Tags.fader).GetComponent<SceneFadeIn> ();
    24.         lastPlayerSighting = GameObject.FindGameObjectWithTag (Tags.gameController).GetComponent<LastPlayerSighting> ();
    25.     }
    26.  
    27.     void Update ()
    28.     {
    29.         if (health <= 0f)
    30.         {
    31.             if (!playerDead)
    32.             {
    33.                 PlayerDying ();
    34.             }
    35.             else
    36.             {
    37.                 PlayerDead ();
    38.                 LevelReset ();
    39.             }
    40.         }
    41.     }
    42.  
    43.     void PlayerDying ()
    44.     {
    45.         playerDead = true;
    46.         anim.SetBool (hash.deadBool, true);
    47.         AudioSource.PlayClipAtPoint (deathClip, transform.position);
    48.     }
    49.  
    50.     void PlayerDead ()
    51.     {
    52.         if (anim.GetCurrentAnimatorStateInfo (0).fullPathHash == hash.dyingState)     // "fullPathHash" instead of "nameHash" (obsolete)
    53.         {
    54.             anim.SetBool (hash.deadBool, false);
    55.         }
    56.  
    57.         anim.SetFloat (hash.speedFloat, 0f);
    58.         playerMovement.enabled = false;
    59.         lastPlayerSighting.position = lastPlayerSighting.resetPosition;
    60.         GetComponent<AudioSource>().Stop ();
    61.     }
    62.  
    63.     void LevelReset ()
    64.     {
    65.         timer += Time.deltaTime;
    66.  
    67.  
    68.         if (timer >= resetAfterDeathTime)
    69.         {
    70.             sceneFadeIn.EndScene ();
    71.         }
    72.     }
    73.  
    74.     public void TakeDamage (float amount)
    75.     {
    76.         health -= amount;
    77.     }
    78. }

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. //using System.Diagnostics.Eventing.Reader;        //removed following compilation error; script works fine without it.
    4. using UnityEngine.Audio;
    5.  
    6. public class PlayerMovement : MonoBehaviour
    7. {
    8.     public AudioClip shoutingClip;
    9.     public float turnSmoothing = 15f;
    10.     public float speedDampTime = 0.1f;
    11.  
    12.     private Animator anim;
    13.     private HashIDs hash;
    14.     private AudioSource audioSource;
    15.     private Rigidbody rb;
    16.  
    17.     void Awake ()
    18.     {
    19.         anim = GetComponent<Animator> ();
    20.         hash = GameObject.FindGameObjectWithTag (Tags.gameController).GetComponent<HashIDs> ();
    21.         audioSource = GetComponent<AudioSource> ();
    22.         rb = GetComponent<Rigidbody> ();
    23.  
    24.         anim.SetLayerWeight (1, 1f);
    25.     }
    26.  
    27.     void FixedUpdate ()
    28.     {
    29.         float h = Input.GetAxis ("Horizontal");
    30.         float v = Input.GetAxis ("Vertical");
    31.         bool sneak = Input.GetButton ("Sneak");
    32.  
    33.         MovementManagement (h, v, sneak);
    34.     }
    35.  
    36.     void Update ()
    37.     {
    38.         bool shout = Input.GetButtonDown ("Attract");
    39.  
    40.         anim.SetBool (hash.shoutingBool, shout);
    41.         AudioManagement (shout);
    42.     }
    43.  
    44.     void MovementManagement (float horizontal, float vertical, bool sneaking)
    45.     {
    46.         anim.SetBool (hash.sneakingBool, sneaking);
    47.  
    48.         if (horizontal != 0f || vertical != 0f)
    49.         {
    50.             Rotating (horizontal, vertical);
    51.             anim.SetFloat (hash.speedFloat, 5.5f, speedDampTime, Time.deltaTime);
    52.         }
    53.         else
    54.         {
    55.             anim.SetFloat (hash.speedFloat, 0f);
    56.         }
    57.     }
    58.  
    59.     void Rotating (float horizontal, float vertical)
    60.     {
    61.         Vector3 targetDirection = new Vector3 (horizontal, 0f, vertical);
    62.         Quaternion targetRotation = Quaternion.LookRotation (targetDirection, Vector3.up);
    63.         Quaternion newRotation = Quaternion.Lerp (rb.rotation, targetRotation, turnSmoothing * Time.deltaTime);
    64.         rb.MoveRotation (newRotation);
    65.     }
    66.  
    67.     void AudioManagement (bool shout)
    68.     {
    69.         if (anim.GetCurrentAnimatorStateInfo (0).fullPathHash == hash.locomotionState)   // "fullPathHash" instead of "nameHash" (obsolete)
    70.         {
    71.             if (!audioSource.isPlaying)
    72.             {
    73.                 audioSource.Play ();
    74.             }
    75.         }
    76.         else
    77.         {
    78.             audioSource.Stop ();
    79.         }
    80.  
    81.         if (shout)
    82.         {
    83.             AudioSource.PlayClipAtPoint (shoutingClip, transform.position);
    84.         }
    85.     }
    86. }

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class LastPlayerSighting : MonoBehaviour
    5. {
    6.     public Vector3 position = new Vector3 (1000f, 1000f, 1000f);
    7.     public Vector3 resetPosition = new Vector3 (1000f, 1000f, 1000f);
    8.     public float lightHighIntensity = 0.25f;
    9.     public float lightLowIntensity = 0f;
    10.     public float fadeSpeed = 7f;
    11.     public float musicFadeSpeed = 1f;
    12.  
    13.     private AlarmLight alarm;
    14.     private Light mainLight;
    15.     private AudioSource panicAudio;
    16.     private AudioSource musicNorm;
    17.     private AudioSource[] sirens;
    18.  
    19.     void Awake ()
    20.     {
    21.         alarm = GameObject.FindGameObjectWithTag (Tags.alarm).GetComponent<AlarmLight> ();
    22.         mainLight = GameObject.FindGameObjectWithTag (Tags.mainLight).GetComponent<Light>();
    23.         musicNorm = GetComponent<AudioSource> ();
    24.         panicAudio = transform.Find ("secondaryMusic").GetComponent<AudioSource>();
    25.         GameObject[] sirenGameObjects = GameObject.FindGameObjectsWithTag (Tags.siren);
    26.         sirens = new AudioSource[sirenGameObjects.Length];
    27.  
    28.         for (int i =0; i < sirens.Length; i++)
    29.         {
    30.             sirens [i] = sirenGameObjects [i].GetComponent<AudioSource>();
    31.         }
    32.     }
    33.  
    34.     void Update ()
    35.     {
    36.         SwitchAlarms ();
    37.         MusicFading ();
    38.     }
    39.  
    40.     void SwitchAlarms ()
    41.     {
    42.         alarm.alarmOn = (position != resetPosition);
    43.  
    44.         float newIntensity;
    45.  
    46.         if (position != resetPosition)
    47.         {
    48.             newIntensity = lightLowIntensity;
    49.         }
    50.         else
    51.         {
    52.             newIntensity = lightHighIntensity;
    53.         }
    54.  
    55.         mainLight.intensity = Mathf.Lerp (mainLight.intensity, newIntensity, fadeSpeed * Time.deltaTime);
    56.  
    57.         for (int i = 0; i < sirens.Length; i++)
    58.         {
    59.             if (position != resetPosition && !sirens [i].isPlaying)
    60.             {
    61.                 sirens [i].Play ();
    62.             }
    63.             else if (position == resetPosition)
    64.             {
    65.                 sirens [i].Stop ();
    66.             }
    67.         }
    68.     }
    69.  
    70.     void MusicFading ()
    71.     {
    72.         if (position != resetPosition)
    73.         {
    74.             musicNorm.volume = Mathf.Lerp (musicNorm.volume, 0f, musicFadeSpeed * Time.deltaTime);
    75.             panicAudio.volume = Mathf.Lerp (panicAudio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
    76.         }
    77.         else
    78.         {
    79.             musicNorm.volume = Mathf.Lerp (musicNorm.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
    80.             panicAudio.volume = Mathf.Lerp (panicAudio.volume, 0f, musicFadeSpeed * Time.deltaTime);
    81.         }
    82.     }
    83. }
     
    Last edited: Jul 11, 2016
  7. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
  8. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    All right, I've finished the tutorial. Like everyone (I guess) the guards animations do not work properly; they walk in circles. The fix provided by @groo79 is not The Solution; the guards bump into the walls and look like they are drunk! :)

    Furthermore, the shooting script doesn't work at all; the guards make awkward gestures when they raise their weapon and the shooting doesn't happen.

    Looks like I'll have to learn more before finishing this tutorial. :)

     
  9. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    Is stealth project now compatible with 5.4?
    Is it possible to bind this project with the roguelike so that you can have roguelike stealth ?
     
  10. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,679
    What do you mean with your last sentence?

    If you're asking if you can combine the projects then download them both and give it a go. You can just download the Stealth project and try it in Unity 5.4 to answer your first question as well.
     
  11. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    443
    hi i'm interested in this tutorial too in unity 5 but where can I find the guide pages..all link on unity site are down

    has someone saved the site pages as html an can share them??
     
  12. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    For example making a roguelike stealth game.
    Maybe they are getting updated for 5.5 release.
     
  13. BerniceChua

    BerniceChua

    Joined:
    Nov 30, 2016
    Posts:
    32
    Hi @ladyonthemoon, thanks for that alternate solution! But I think I found the Wrap Mode.

    Step 1: Please select your Animation (in this case "cctvSweep") inside your Assets folder.
    Step 2: In the Inspector, please click on the little menu beside the lock, to get the dropdown menu, then choose "Debug".
    Unity-Change-Inspector-From-Normal-To-Debug Mode.PNG
    Step 3: Once you click "Debug", the Inspector panel changes into the Debug panel. From here, you can see the "Wrap Mode" field. Please check the box that says "Legacy", then click on the dropdown menu beside it, then choose "Ping Pong". Unity-WrapMode.PNG

    When you do this, and you attach "cctvSweep" as a component into the Inspector view of "prop_cctvCam_joint", the component will now have the title of "Animation" instead of "Animator" like in all the 5.x versions.

    I hope that's helpful! ^_^

    Anyway, in the new versions of Unity, I guess it's preferable for the WrapMode to be done in the scripts instead of the Inspector? Here's the documentation that I found: https://docs.unity3d.com/ScriptReference/WrapMode.html
     
    Last edited: Feb 3, 2017
    APSchmidt likes this.
  14. BerniceChua

    BerniceChua

    Joined:
    Nov 30, 2016
    Posts:
    32
    The new URI for downloading the Stealth Tutorial is now here: https://www.assetstore.unity3d.com/en/#!/content/7677

    I found it there when they were doing the Merry Fragmas tutorials. ^_^
     
    konsic likes this.
  15. BerniceChua

    BerniceChua

    Joined:
    Nov 30, 2016
    Posts:
    32
    Hi @Vagabond820, thanks for listing all the differences between the versions! ^_^ I just noticed that your link is the old one. To download the Stealth tutorial, this has now been moved to the Asset Store: https://www.assetstore.unity3d.com/en/#!/content/7677

    I found it there when they did the Merry Fragmas tutorial. (That's the only reason I even knew about this Stealth Game tutorial and wanted to learn it.)
     
    Last edited: Feb 6, 2017
  16. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    3,831
    Thanks for the update! Much appreciated! :) (The choice of emoticons here should be improved.)
     
    BerniceChua likes this.
  17. BerniceChua

    BerniceChua

    Joined:
    Nov 30, 2016
    Posts:
    32
    APSchmidt likes this.
  18. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    Thanks. Could you tell me is it possible to follow this tutorial but with isometric 2D background ?
     
  19. jackhearts

    jackhearts

    Joined:
    Apr 5, 2013
    Posts:
    103
    My advice would be to follow the tutorial verbatim before trying to adapt it, otherwise you'll be opening up a world of pain. It'll be easier to then start a new project and transfer some of that knowledge across. The game is based on 3D geometry though so you may not find a huge amount of relevance.
     
    unity_z9q1CNxNma_dCA and konsic like this.
  20. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    778
    Hi folks, just wanted to ask if you are keeping this updated version of Stealth anywhere on github or similar? would love access to it to see how it fares in Unity 2018 if possible..
     
    konsic, alxcancado and h0x91b like this.
  21. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    3,831
    Thank you for that! :)
     
  22. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,679
    @willgoldstone

    I'm pretty sure I have most, if not all, Unity example projects somewhere in my archives. Even dating as far back as Unity 2.x. I've disagreed quite a bit with Unity over the years on how you manage your older projects so I've always felt it was safest to back them up before you, for reasons I don't understand, permanently remove any trace of them, Bootcamp and Unity Labs being the worst offenders in my opinion, both of which I have copies of for various Unity versions.

    I'm pretty sure I have the original Stealth somewhere upgraded for various Unity versions, but I also have this project I made based on Stealth: http://twiik.net/projects/stealth-extended

    And I've not had any problems upgrading old projects like these through various Unity versions so I doubt it would pose many problems upgrading this to 2018 either.

    I'm in the process of finishing an upgrade of the Unity Labs project for 2018 as well which I intend to upload to my site, both for HDRP and the normal pipeline. In my opinion this is still the best example project Unity has made, even compared to Book of the dead or any of the newest samples. It's a shame you released it in such a buggy state, never updated it, then teased an updated version, but never released that either.
     
  23. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    3,831
    Hi,
    I'd never heard of Bootcamp before but I have downloaded the Unity lab as it is available now on the store. If you do have the original projects (and the videos?) is there any way your could share them somewhere?
    Thank you!
     
  24. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,679
    Is it? I can't find it. I'm not talking about the Robot Lab which is laughably low quality compared to Unity Labs, I'm talking about the project which I believe shipped with Unity 5.x. There's no tutorial or anything associated with it, it just shipped with Unity as an example project.

    Here's a video introducing the original version:

    And then they talked about (promised) an updated version which they later teased in a video showcasing one of the early iterations of the unity post processing stack:

    But this version was never released.

    Bootcamp was the example project for early versions of Unity 3.x. I'm not aware of any official videos that still exist showcasing this project, but here's an unoffical one:

    You can download the project from my site:
    http://twiik.net/resources/bootcamp-0

    Unity Labs may very well still ship as an example project with Unity 5.x for all I know, but both Bootcamp and Unity Labs were released in fairly "half-assed" states, but could easily have been polished a bit if somebody cared. And the same projects could and should in my opinion at least be hosted on the Asset Store alongside other official projects.

    Unity Labs is so high quality in my opinion that you could make a game using the assets from it today and people wouldn't question it. Bootcamp is a bit more rough by todays standards, but there's a lot of great assets in there nonetheless. The main character is very high quality and has hundreds of quality animations. In fact I use the character and the animations in a project I'm working on at the moment and I also use a lot of the scripts as references/inspiration.

    I'll upload the Unity Labs project as well sooner or later, but like I said it may very well still be included with Unity 5.x.
     
    Last edited: Nov 26, 2018
    APSchmidt likes this.
  25. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    3,831
    You're right, the Unity Lab I have is more probably the Robot Lab... Well, looks like Unity Lab is gone forever... https://assetstore.unity.com/packages/essentials/unity-labs-33785

    Is this all what remains of it? https://assetstore.unity.com/packages/essentials/tutorial-projects/corridor-lighting-example-33630

    Thank you for Bootcamp! ;)

    Edit: unfortunately, all the meta files are missing in the archive, making the project unusable... Thanks anyway.
     
    Last edited: Nov 26, 2018
  26. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,679
    They're volatile and get rebuilt by Unity on startup. Same as GI data etc. It just adds a ton of unnecessary file size to a project imo. I always delete it from projects that I'm not actively working on.
     
  27. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    3,831
    These meta files are necessary; they contain all date as to the contents. Without them everything must be remade: prefabs, materials, scene, everything. All the materials are empty and all the prefabs and objects are missing their materials, their scripts and so on. Maybe you should load the content of the archive in Unity to see what I mean. :)
     
    Last edited: Nov 27, 2018
  28. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    3,831
    @willgoldstone

    Just finished the project with 2019.1.0a11; didn't have much difficulty, even with the animations, and the game works perfectly.

    I now need to tweak it to my liking. :)
     
  29. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    3,831
  30. subtlefly

    subtlefly

    Joined:
    Jun 19, 2013
    Posts:
    20
    Hey Team,
    I am trying to download the original project but the link at the top of this post is broken, has anyone got a project that will work with current version of unity that I can download and play around with?
    Thanks
    sub
     
  31. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    3,831
    I have one but I don't know if I'm allowed to share it now that it's been deprecated. @willgoldstone

    The project works with 2018.x and 2019.x.
     
  32. waved

    waved

    Joined:
    Jan 25, 2020
    Posts:
    8
    Yes, In know I am working on this tutorial 7 years after its release. So much has changed from then, but it's the kind of game I want to make I tried.

    For some reason I can't get the robots to shoot the player. They hear, they chase, they trigger the alarm, but goddam the won't shoot.

    Are there any known issues? What script should I look for the problem in?

    Send help
     
  33. waved

    waved

    Joined:
    Jan 25, 2020
    Posts:
    8
    http://twiik.net/projects/stealth-extended

    Have fun
     
unityunity