Author Topic: Error on TNAutoCreate  (Read 10843 times)

Noi14

  • Jr. Member
  • **
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 57
    • View Profile
Error on TNAutoCreate
« on: March 15, 2014, 01:00:03 PM »
Hi,
I have got a problem with TNAutoCreate, sometimes I have got problem when it creates object, but I don't konw where the problem is:

  1. (Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WebPlayerGenerated/UnityEngineDebug.cpp Line: 53)
  2.  
  3. ArgumentException: failed to convert parameters
  4.   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
  5.  
  6. System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  7.  
  8.   at System.Reflection.MonoProperty.SetValue (System.Object obj, System.Object value, BindingFlags invokeAttr, System.Reflection.Binder binder,
  9.  
  10. System.Object[] index, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  11.  
  12.   at System.Reflection.PropertyInfo.SetValue (System.Object obj, System.Object value, System.Object[] index) [0x00000] in <filename unknown>:0
  13.  
  14.   at TNAutoSync.OnSync (System.Object[] val) [0x00000] in <filename unknown>:0
  15.  
  16.   at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
  17.  
  18.   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
  19.  
  20. System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  21. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
  22.   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
  23.  
  24. System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  25.  
  26.   at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
  27.  
  28.   at TNet.UnityTools.ExecuteAll (TNet.List`1 rfcs, Byte funcID, System.Object[] parameters) [0x00000] in <filename unknown>:0
  29.  
  30.   at TNObject.Execute (Byte funcID, System.Object[] parameters) [0x00000] in <filename unknown>:0
  31.  
  32.   at TNObject.Start () [0x00000] in <filename unknown>:0
  33.  
  34. (Filename:  Line: -1)
  35.  
This error appear sometimes not always. What's wrong?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Error on TNAutoCreate
« Reply #1 on: March 15, 2014, 06:46:47 PM »
That seems to be caused by TNAutoSync, not TNAutoCreate. TNAutoCreate simply creates an object on startup.

TNAutoSync keeps the specified values in sync. There should only be one TNAutoSync per instantiated TNObject -- and if you have multiple TNAutoSync scripts or multiple TNObjects nested, it won't work.

Noi14

  • Jr. Member
  • **
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 57
    • View Profile
Re: Error on TNAutoCreate
« Reply #2 on: March 16, 2014, 08:55:07 AM »
Thank you for your reply.
I don't have some TNAutoSync nested on the object.

I have the player's object that have 2 scripts that extend class TNBehaviour:
public class GamerPlayerEach : TNBehaviour
e
public class GamerPlayer : TNBehaviour

Can I do this? Because it's more easier for me to divide scripts.

Player's object have got only 1 TNAutoSync that is setted as:
  1. Transform -> rotation
  2. Updates per second: 3
  3. Saved on server: yes
  4. Important: yes
  5. Only owner can sync: yes
  6.  

I have a script that synchronize manually the position and the direction of the movement to be performed:
  1. void Start()
  2. {
  3. // Resync
  4. if(tno.isMine)
  5. {
  6. StartCoroutine(AvviaResync());
  7. }
  8. }
  9. IEnumerator AvviaResync()
  10. {
  11. while(true)
  12. {
  13. yield return new WaitForSeconds(0.10f);
  14. tno.Send("resync", TNet.Target.Others, transform.position, movimento);
  15. }
  16. }
  17. [RFC]
  18. void resync(Vector3 myposition, Vector3 destinazione)
  19. {
  20. transform.position = myposition;
  21. movimento = destinazione;
  22. }
  23.  

I see the errors by unity, so as it should be easier to understand the problem, and it appear to me this problem:
  1. Exception has been thrown by the target of an invocation.
  2. TNAutoSync.OnSync (System.Int32)
  3. UnityEngine.Debug:LogError(Object)
  4. TNet.UnityTools:PrintException
  5. (Exception, CachedFunc, Object[]) (at Assets/Library/TNet/Client/TNUnityTools.cs:83)
  6. TNet.UnityTools:ExecuteAll(List`1, Byte, Object[]) (at
  7. Assets/Library/TNet/Client/TNUnityTools.cs:161)
  8. TNObject:Execute(Byte, Object[]) (at Assets/Library/TNet/Client/TNObject.cs:311)
  9. TNObject:Start() (at
  10. Assets/Library/TNet/Client/TNObject.cs:258)
  11.  
  12.  
  1. failed to convert parameters
  2. GamePlayer.resync (System.Int32, System.String)
  3. UnityEngine.Debug:LogError(Object)
  4. TNet.UnityTools:PrintException(Exception,
  5. CachedFunc, Object[]) (at Assets/Library/TNet/Client/TNUnityTools.cs:83)
  6. TNet.UnityTools:ExecuteAll(List`1, String, Object[]) (at
  7. Assets/Library/TNet/Client/TNUnityTools.cs:192)
  8. TNObject:Execute(String, Object[]) (at Assets/Library/TNet/Client/TNObject.cs:322)
  9. TNObject:Start() (at
  10. Assets/Library/TNet/Client/TNObject.cs:257)
  11.  
  12.  

I don't know why the error signs: GamePlayer.resync (System.Int32, System.String)
When I switch 2 Vector3 as parameters.

One thing that should be useful is that I have the host that must press the start's button, when he press the start's button I send an RFC to all the client, and all toghether create the GameObjectPlayer.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Error on TNAutoCreate
« Reply #3 on: March 16, 2014, 12:40:23 PM »
Quote
Exception has been thrown by the target of an invocation.
TNAutoSync.OnSync (System.Int32)
This points that an exception has been thrown inside the OnSync function -- such as a null reference exception. Are you using the latest from the asset store? I could have sworn I've added a more detailed log message to that. Might be in the Pro version though.

If you've ever set the channel to be persistent, then TNet has saved your RFCs from previous executions. Find and delete server.dat file -- that's where everything gets saved.

Quote
failed to convert parameters
GamePlayer.resync (System.Int32, System.String)
This means that the saved RFC was "(int, string)" before. Did you change the function definition at some point? As I mentioned, deleting server.dat should fix that for you.

Noi14

  • Jr. Member
  • **
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 57
    • View Profile
Re: Error on TNAutoCreate
« Reply #4 on: March 16, 2014, 01:26:41 PM »
Thank you for your reply,
Yes, I'm using the latest version from asset store, I have recompiled the server but I modified only the number of version that is used to connect, the rest is esactly as I've bring it in the asset store.
Channel is not permanent, and in the linux server I don't see the file server.data
In the linux server I launch mono command to start it, and in the same folder of .exe there are no file server.dat
I've never edit RFC.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Error on TNAutoCreate
« Reply #5 on: March 17, 2014, 01:40:46 AM »
So what's calling your resync function with a string instead of a 2nd vector?

Noi14

  • Jr. Member
  • **
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 57
    • View Profile
Re: Error on TNAutoCreate
« Reply #6 on: March 17, 2014, 05:18:21 AM »
I have only that call to resync function when I'm using search function in the entire project. So it never sends a string instead the second vector.
I'm 100% sure of this

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Error on TNAutoCreate
« Reply #7 on: March 18, 2014, 10:05:54 PM »
Looking at the stack trace, TNObject.Start function is what ultimately triggers the issue. Without the code in front of me I can't be 100% certain (I am at GDC2014 right now, away from home), but I'm guessing it tries to execute cached callbacks -- RFCs that arrived before the object was created... which should technically never happen seeing as all object creation messages always arrive first. Put some Debug.Log statements in there. Check what the TNObject's ID is when it's trying to execute RFCs on startup.

Noi14

  • Jr. Member
  • **
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 57
    • View Profile
Re: Error on TNAutoCreate
« Reply #8 on: March 25, 2014, 04:04:23 PM »
I remove TNAutoSync on GameObject and I use only my resync.
But I still have the problem (one of the problem?) that some GameObject created with TNAutoCreate are placed to position 0,0,0 instead of the specified position and I have the errors.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Error on TNAutoCreate
« Reply #9 on: March 26, 2014, 03:33:49 AM »
All TNAutoCreate does inside is
  1. TNManager.Create(prefab, transform.position, transform.rotation, persistent);
So as long as the object is in the position you want it to be created, it will be created there. I don't know what's going wrong in your case, so all I can suggest is debug it by eliminating things until you narrow down the cause.