Search Unity

Upgraded Project to Unity 4 and Script Stopped Working

Discussion in 'Scripting' started by SiMULOiD, Jan 11, 2014.

  1. SiMULOiD

    SiMULOiD

    Joined:
    Dec 23, 2013
    Posts:
    126
    Hi all,

    Can someone please tell me why this script, which was working admirably in Unity 3 is no
    longer responsive after upgrading to 4? I don't get any errors in the console, and it compiles, but it doesn't
    work all the same.
    Any ideas?

    Thanks,
    Greg

    Code (csharp):
    1.  
    2.  
    3. var deadReplacementPosition : Vector3;
    4. var deadReplacementRotation : Quaternion;          
    5. var RandomDeadReplacements : Rigidbody[];
    6. var RandomDeadReplacements2 : Rigidbody[];
    7.  var deadReplacement : GameObject;
    8. var hit : RaycastHit;
    9. var dieSound : AudioClip;
    10. var initialDelay = 1.0;
    11. var fadeSpeed = 1.0;
    12. var explosion : Transform;
    13. var damagesound : AudioClip;
    14. var myTransform : Transform;
    15. var OBJECT1 : GameObject;
    16. function Awake() {
    17.    myTransform = transform; // this objects transform
    18. }
    19.  
    20. function Update () {
    21.    //for (var evt : iPhoneTouch in iPhoneInput.touches) {
    22.      // if (evt.phase == iPhoneTouchPhase.Ended) {
    23.              
    24.  
    25.                   for (var event : iPhoneTouch in iPhoneInput.touches) {
    26.                    
    27.                    
    28.                     if(event.tapCount == 1  event.phase == iPhoneTouchPhase.Began)
    29.        
    30.              
    31.         var ray = camera.main.ScreenPointToRay(event.position);
    32.  
    33.        
    34.        
    35.          if (Physics.Raycast(ray, hit, 1000) ) {
    36.             var hitObject : GameObject = hit.transform.gameObject;
    37.             var hitTransform : Transform = hitObject.transform;
    38.             if ( hitObject.tag == "TEST" ) {
    39.                if ( myTransform.position.x == hitTransform.position.x) {       // matches x position
    40.                   if ( myTransform.position.z == hitTransform.position.z) {
    41.                     if ( myTransform.position.y == hitTransform.position.y) {  // matches z position
    42.                      // so this is the object touched in the 2d space
    43.                      deadReplacementPosition = hit.transform.position;
    44.                      deadReplacementRotation = hit.transform.rotation;
    45.                  
    46.  
    47.                  
    48.                        //Destroy( hit.collider.gameObject );
    49.                      
    50.                      // Play a dying audio clip
    51.                      if (dieSound) {
    52.                         AudioSource.PlayClipAtPoint(dieSound, transform.position);
    53.                      }
    54.                      
    55.  
    56.    Instantiate(deadReplacement,Vector3(0, 3.616913, 0), Quaternion.identity);
    57.  
    58.      
    59.     }}}}}}}
    60.    
    61.    
    62.  
    63.  
    64.  
    65.  
     
  2. jackmott

    jackmott

    Joined:
    Jan 5, 2014
    Posts:
    167
    Have you tried looking at the error log?

    In windows7 it will be in:
    C:\Users\YOURNAME\AppData\Local\Unity\Editor
     
  3. SiMULOiD

    SiMULOiD

    Joined:
    Dec 23, 2013
    Posts:
    126
    Hi jackmott,

    I checked my error log and don't see anything. It's as if the code is no longer recognized. I tried
    to make a new jscript and cut / paste, but still no good.
    Was there something changed between Unity 3 and 4 to make the above stop working?
     
  4. SiMULOiD

    SiMULOiD

    Joined:
    Dec 23, 2013
    Posts:
    126
    SOLVED! My iPhoneTouch events were deprecated. Quick fix.