Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Voxel

Pages: [1] 2 3
1
OK, it's fixed, but I had to move scripts around and rework it. There must be something I am not understanding *scratches head*

What I did was to move the chat toggle scripts to a gameobject that is not Created by TNManager. That gameobject also contains the example chat script.

The scripts were located on the player avatar that is created by  TNManager.Create on start. Could that be the cause?

If you can shed some light that would be great but I know your are busy Arenmook and I appreciate the help you have already given, so don't worry too much! Thanks :)

2
TNObject is not being disabled / enabled at any point, the only objects being enabled /disabled are in the script examples I posted.
Let's focus on the RFC situation:

The @RFC is always called successfully.

This prints as it should when the @RFC is called:
print("TNO RECIEVED" + chatModeActive);

This does nothing at all even the the above works:
test += 1;

How can this super simple increase of an int value fail? I am also going to try some other testing tonight out of desperation.....

Update: Still testing and if I have just this as the @RFC:
  1. @RFC
  2. function ChatMode (chatModeActive : boolean){
  3.         print("TNO RECIEVED" + chatModeActive); // <<This works!
  4.         print("This is attached to: " + this.gameObject);// << Exception has been thrown by the target of an invocation error
  5. }
  6.  

Not sure if that could be a clue? I'm really trying to get to the bottom of this Arenmook, sorry to be a pain :(

3
No. Just the component gets enabled/disabled.

4
Hmmm, I've been down that route and just checked again. The variable initialization has been set in both Awake and OnEnable. If have also set them in the inspector and I get the same results in all cases. I have also tried getcomponent in the ChatMode function, but still no luck.

To explain further the chat window is not opened on the start of the game. It is called when a player presses the Escape key to start a chat.

To test further I have added a simple increase/decrease int, this also fails to do anything when the function is called as @RFC, but works fine when called in the start function. I have updated this script in my previous post.

I have also added to my previous post the trigger script as well (just in case!)

I feel I am going mad Arenmook! Or am I just being a bit stupid? ;)

5
Yep, spot on, that is exactly what I found, but it doesn't make sense. So I changed the script to be dedicated as an @RFC for simplicity/debug purposes. Here is the script:

Here is the 'Trigger Script':

  1. #pragma strict
  2.  
  3. var chatScript : ExampleChat;
  4. var playerMoveScript : playerPhysixMoveAim;
  5. var playerShootScript : playerShootV2;
  6. var chatModeEnabled : boolean;
  7.  
  8. var tno : TNObject;
  9.  
  10. //-------------------------------------------------------------------------------------------------------
  11. //-------------------------------------------------------------------------------------------------------
  12.  
  13. function Awake (){
  14.     if(!TNManager.isThisMyObject) {
  15.           Destroy (this);
  16.     }
  17. }
  18.  
  19. //-------------------------------------------------------------------------------------------------------
  20. //-------------------------------------------------------------------------------------------------------
  21.  
  22. function Start () {
  23.  
  24.     chatScript = GameObject.Find("--Level--/GUI/Chat").GetComponent(ExampleChat);
  25.         playerMoveScript = GetComponent(playerPhysixMoveAim);
  26.         playerShootScript = GetComponent(playerShootV2);
  27.         chatScript.enabled = false;
  28.         tno = GetComponent(TNObject);
  29.        
  30. }
  31.  
  32. //-------------------------------------------------------------------------------------------------------
  33. //-------------------------------------------------------------------------------------------------------
  34.  
  35. function Update () {
  36.  
  37.                 if(Input.GetKeyDown(KeyCode.Escape)){
  38.                         chatScript.enabled = !chatScript.enabled;
  39.                         playerMoveScript.enabled = !playerMoveScript.enabled;
  40.                         playerShootScript.enabled = !playerShootScript.enabled;
  41.                         chatModeEnabled = !chatModeEnabled;
  42.                         tno.Send("ChatMode", Target.Others, chatModeEnabled);
  43.                 }
  44. }
  45.  
  46. //-------------------------------------------------------------------------------------------------------
  47. //-------------------------------------------------------------------------------------------------------
  48.  




  1. #pragma strict
  2.  
  3. var chatScript : ExampleChat;
  4. var playerMoveScript : playerPhysixMoveAim;
  5. var playerShootScript : playerShootV2;
  6.  
  7. var test : int;
  8. //-------------------------------------------------------------------------------------------------------
  9. //-------------------------------------------------------------------------------------------------------
  10.  
  11. function Awake () {
  12.  
  13.     chatScript = GameObject.Find("--Level--/GUI/Chat").GetComponent(ExampleChat);
  14.         playerMoveScript = GetComponent(playerPhysixMoveAim);
  15.         playerShootScript = GetComponent(playerShootV2);
  16. }
  17.  
  18. //-------------------------------------------------------------------------------------------------------
  19. //-------------------------------------------------------------------------------------------------------
  20.  
  21. @RFC
  22. function ChatMode (chatModeActive : boolean){
  23.                 print("TNO RECIEVED" + chatModeActive);
  24.                
  25.                 print(chatModeActive);
  26.                 print(playerMoveScript);
  27.                 print(playerShootScript);
  28.                
  29.                 if(chatModeActive == true){
  30.                         if(chatScript){
  31.                                 chatScript.enabled = true;
  32.                         }
  33.                         if(playerMoveScript){
  34.                                 playerMoveScript.enabled = false;
  35.                         }
  36.                         if(playerShootScript){
  37.                                 playerShootScript.enabled = false;
  38.                         }
  39.                        
  40.                         test += 1;
  41.                        
  42.                 }
  43.                
  44.                 if(chatModeActive == false){
  45.                         if(chatScript){
  46.                                 chatScript.enabled = false;
  47.                         }
  48.                         if(playerMoveScript){
  49.                                 playerMoveScript.enabled = true;
  50.                         }
  51.                         if(playerShootScript){
  52.                                 playerShootScript.enabled = true;
  53.                         }
  54.                        
  55.                         test -= 1;
  56.                 }
  57. }

Now here is the weird bit. Looking at the script in the Unity Inspector, all scripts show as found, yet the print statements show as null for the playerMoveScript, and the playerShootScript. The script works without the "Exception has been thrown by the target of an invocation" error because of the if statements.

So why when the scripts are shown as found am I getting a null from the @RFC function?
If I call ChatMode(true); in function Start it works as it should. Is there something I am not understanding about TNet or multiplayer networking in general?

6
Hi I know this is an open ended question but I bump into this error a fair bit. What exactly does it mean?

For example today I have this error in a script that makes the chat window open/close on all clients by any client who wants to start it:
Exception has been thrown by the target of an invocation.
chatWindowToggle.ChatMode (System.Boolean)

Below is both scripts. They are both on the same gameobject....


Here is the script @RFC:
  1. #pragma strict
  2.  
  3. var chatScript : ExampleChat;
  4. var playerMoveScript : playerPhysixMoveAim;
  5. var playerShootScript : playerShootV2;
  6. var chatModeEnabled : boolean;
  7.  
  8. var tno : TNObject;
  9.  
  10. //-------------------------------------------------------------------------------------------------------
  11. //-------------------------------------------------------------------------------------------------------
  12.  
  13. function Awake (){
  14.     if(!TNManager.isThisMyObject) {
  15.           Destroy (this);
  16.     }
  17. }
  18.  
  19. //-------------------------------------------------------------------------------------------------------
  20. //-------------------------------------------------------------------------------------------------------
  21.  
  22. function Start () {
  23.  
  24.     chatScript = GameObject.Find("--Level--/GUI/Chat").GetComponent(ExampleChat);
  25.         playerMoveScript = GetComponent(playerPhysixMoveAim);
  26.         playerShootScript = GetComponent(playerShootV2);
  27.         chatScript.enabled = false;
  28.         tno = GetComponent(TNObject);
  29.        
  30. }
  31.  
  32. //-------------------------------------------------------------------------------------------------------
  33. //-------------------------------------------------------------------------------------------------------
  34.  
  35. function Update () {
  36.  
  37.                 if(Input.GetKeyDown(KeyCode.Escape)){
  38.                         chatScript.enabled = !chatScript.enabled;
  39.                         playerMoveScript.enabled = !playerMoveScript.enabled;
  40.                         playerShootScript.enabled = !playerShootScript.enabled;
  41.                         chatModeEnabled = !chatModeEnabled;
  42.                         tno.Send("ChatMode", Target.Others, chatModeEnabled);
  43.                 }
  44. }
  45.  
  46. //-------------------------------------------------------------------------------------------------------
  47. //-------------------------------------------------------------------------------------------------------
  48.  
  49. @RFC
  50. function ChatMode (chatModeActive : boolean){
  51.                 print("TNO RECIEVED" + chatModeActive);
  52.                 if(chatModeActive == true){
  53.                         chatScript.enabled = true;
  54.                         playerMoveScript.enabled = false;
  55.                         playerShootScript.enabled = false;
  56.                 }
  57.                
  58.                 if(chatModeActive == false){
  59.                         chatScript.enabled = false;
  60.                         playerMoveScript.enabled = true;
  61.                         playerShootScript.enabled = true;
  62.                 }
  63. }

What am I doing wrong?

7
TNet 3 Support / Re: Raycast Question Object Position Problem
« on: August 01, 2013, 04:04:38 PM »
Never mind fixed it! My collider was a child of the object with AntiJitter so it was always looking in the wrong place.

8
TNet 3 Support / Raycast Question Object Position Problem
« on: August 01, 2013, 03:57:33 PM »
Hi,

I am using raycasting to detect targets, however when they travel at speed the raycasts seem to lag behind and start miss.

I have the rigidbody in the root separate from the renderer, and I am using AntiJitter on the Renderer, and TNAutoSync to sync the transform position and rotation. The collider is attached to the same object as the rigidbody.

I've played around with the SyncRigidbody script, and also the rigidbody setting in TNAutosync, thinking it's a rigidbody or collider position problem.

Am I on the right track? I am open to any suggestions!


9
TNet 3 Support / Feature Request
« on: July 30, 2013, 06:55:04 PM »
Hi,

I would love it if TNet kept a tally of TNObject Sends sent and @RFC received by the client. It would be useful for debugging, checking efficiency, etc.

Thanks!

10
TNet 3 Support / Re: Disconnecting from host while level loads
« on: July 23, 2013, 07:14:59 AM »
Brilliant! Thanks ArenMook!

11
TNet 3 Support / Disconnecting from host while level loads
« on: July 22, 2013, 10:26:02 AM »
Hi,

I have a level that is built procedurally, if I choose to build a large world that takes about 5 seconds to build (especially in the Game Window inside Unity), I get disconnected. Is there was way to keep the connection alive?

Thanks.

12
TNet 3 Support / Find remote player avatar
« on: July 21, 2013, 02:21:16 PM »
Hi,

I need to build a list of remote players avatars as a list of Transforms. Ideally I would like to use the TNManager.players array, as this is the first place to get updated when someone leaves the game.

I am wondering if there is an in-built method to quickly find the gameobject that is created when they join.

If not I will use more traditional methods to do it.

Thanks!

13
Ahhh, OK, so if I leave the ID number of the child TNObject as 0, it will show as zero but will be still accessible as normal?

14
The TNObject is in a child of the gameobject that is instantiated by TNManager.Create(prefab) - Is it only TNObjects in the root of the instantiated object that are assigned ID numbers? Or should all TNObjects that are part of the TNManager.Create instantiated gameobject be assigned unique ID numbers?


15
Hi,

This is probably something I am not understanding, but I though TNObject automatically assigns a unique ID number to itself.

For example I have a TNObject in a child of a parent that is being spawned using TNet. I have a script which has an @RFC in the child object that the TNObject is attached to.

Is this right?

Thanks!

Pages: [1] 2 3