Search Unity

What should I do when the respawn point is blocked?

Discussion in 'Scripting' started by austin_farmer90, Jul 31, 2014.

  1. austin_farmer90

    austin_farmer90

    Joined:
    May 4, 2014
    Posts:
    42
    Hey guys, I'm having some trouble with a respawn function. About 95% of the time it works fine but if someone else happens to be respawning it throws this error

    Code (CSharp):
    1. MissingFieldException: System.Single.magnitude
    2. Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.FindExtension (IEnumerable`1 candidates)
    3. Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.Create (SetOrGet gos)
    4. Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.CreateGetter ()
    5. Boo.Lang.Runtime.RuntimeServices.DoCreatePropGetDispatcher (System.Object target, System.Type type, System.String name)
    6. Boo.Lang.Runtime.RuntimeServices.CreatePropGetDispatcher (System.Object target, System.String name)
    7. Boo.Lang.Runtime.RuntimeServices+<GetProperty>c__AnonStorey17.<>m__C ()
    8. Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
    9. Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
    10. Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
    11. Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name)
    12. UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name)
    I tried using a try catch statement but that didn't seem to help. Has anyone dealt with this before or does anyone know what I should do?
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    how are you doing the respawning? can we see the code?
     
  3. austin_farmer90

    austin_farmer90

    Joined:
    May 4, 2014
    Posts:
    42
    The code is pretty extensive, but heres the parts that handle respawning.

    Code (JavaScript):
    1. function Update () {
    2.     if(CurrentSpeed<10){
    3.         RespawnCounter+=Time.deltaTime;
    4.         if(RespawnCounter > RespawnWait){
    5.             try{
    6.             Respawn();
    7.             }catch(e){
    8.            
    9.             }
    10.         }
    11.     }  
    12.     switch(State){
    13.     case "Racing":
    14.         MoveToDest();
    15.     break;
    16.     }
    17.    
    18. }
    19.  
    20. function Respawn(){
    21. try{
    22. var GateIndex = PlaceScript.GateIndex;
    23. var gates = RaceController.Gates;
    24. if(GateIndex == 0){
    25. var targ = gates[0].GetComponent(GateController).RespawnPathTarget;
    26. transform.position = gates[0].gameobject.transform.position;
    27. AssignedZone = targ.GetComponent(PathNodeSetup).AssignedZone;
    28. LocalPathNodeAR = AssignedZone.GetComponent(ZoneSetup).PathAR;
    29. PathTarget = gates[0].GetComponent(GateController).RespawnPathTarget;
    30. PathIndex = gates[0].GetComponent(GateController).RespawnPathIndex;
    31. }else{
    32. var targ2 = gates[GateIndex - 1].GetComponent(GateController).RespawnPathTarget;
    33. transform.position = gates[GateIndex - 1].gameObject.transform.position;
    34. AssignedZone = targ2.GetComponent(PathNodeSetup).AssignedZone;
    35. LocalPathNodeAR = AssignedZone.GetComponent(ZoneSetup).PathAR;
    36. PathTarget = gates[GateIndex - 1].GetComponent(GateController).RespawnPathTarget;
    37. PathIndex = gates[GateIndex - 1].GetComponent(GateController).RespawnPathIndex;
    38. }
    39. transform.localEulerAngles.z = 0;
    40. transform.localEulerAngles.y = 0;
    41. RespawnCounter = 0;
    42. }catch(e){
    43.  
    44. }
    45. }

    Any ideas?