Author Topic: <TNObject>().isMine Issues  (Read 4393 times)

blueagardq15

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
<TNObject>().isMine Issues
« on: July 31, 2015, 05:59:42 AM »
Hello, A player creates a server and joins channel, and everything goes well, but when The Client joins Server and channel, TNObject.Ismine Acts as it does not apply to anyone as I can see his First person features that I blocked off if the TNObject is not yours. Here is my sample code

  1. if (GetComponent<TNObject>().isMine)
  2.                 {
  3.                 //MINE: local player, simply enable the local scripts
  4.             GetComponent<SimpleSmoothMouseLook>().enabled = true;
  5.             camera.enabled = true;
  6.                         FPS.enabled = true;
  7.             FPSC.SetActive(true);
  8.                 }
  9.                 else
  10.                 {          
  11.                         camera.enabled = false;
  12.                         //FPS.enabled = false;
  13.                         GetComponent<SimpleSmoothMouseLook>().enabled = false;
  14.             GetComponentInChildren<SimpleSmoothMouseLook>().enabled = false;
  15.             FPSC.SetActive(false);
  16.                                 foreach(SkinnedMeshRenderer go in RemoteMeshes)
  17.                                 {
  18.                                         go.enabled = true;
  19.                                 }
  20.                 }

It should disable because the TNObject is not Mine, but Instead for everyone it says that it is mine for everysingle person that joins. That will be a big problem.

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: <TNObject>().isMine Issues
« Reply #1 on: July 31, 2015, 01:15:50 PM »
Very strange. Can you place a Debug.Log to verify the right block is being executed?
One possible thing I can think of: GetComponent<TNObject>().isMine is evaluating properly, but your enable / disable code doesn't do what you intended.
Another thing: Are you instantiating the object with TNManager.Create?

Also, if you use GetComponent<TNObject>() a lot in a script, you should derive from TNBehaviour. This allows you to use its member "tno". Saves you some calls to GetComponent ;)

blueagardq15

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: <TNObject>().isMine Issues
« Reply #2 on: July 31, 2015, 03:21:26 PM »
Wow  lol thanks

blueagardq15

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: <TNObject>().isMine Issues
« Reply #3 on: August 04, 2015, 10:09:46 AM »
I am not understanding, I do tno.ismine,, but when I create a player and I disable scripts that are not mine... they still seem to be enabled for other player

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: <TNObject>().isMine Issues
« Reply #4 on: August 04, 2015, 04:34:59 PM »
without seeing your code and how you have your prefab setup - there is little chance anyone can help you.

i would suggest setting up your player as if it was an ememy.  then you would only have to turn on the components that make it usable as a controller.

searching for "gameplayer" should give you a good direction to figure this out.

blueagardq15

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: <TNObject>().isMine Issues
« Reply #5 on: August 04, 2015, 06:00:10 PM »
Ima run a test with editor to see how it works out

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: <TNObject>().isMine Issues
« Reply #6 on: August 05, 2015, 07:33:48 AM »
It's all in how the object is created. Whoever creates the object will have its "tno.isMine" evaluate to "true".

You need to create objects using TNManager.Create. If you just use GameObject.Instantiate, you are making local objects, not networked objects. Likewise if your object is a part of the scene, its owner flag is undefined.

So in short, make sure you create your player avatar using TNManager.Create.