Welcome,
Guest
. Please
login
or
register
.
May 02, 2026, 08:32:34 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
TNet 3 Support
»
Sync customProperties
« previous
next »
Print
Pages: [
1
]
Author
Topic: Sync customProperties (Read 6550 times)
Elmo loves cookies
Jr. Member
Thank You
-Given: 60
-Receive: 1
Posts: 62
Sync customProperties
«
on:
March 08, 2017, 01:06:06 PM »
needed take some customProperties from Tnet.Player
if we can get player, by: Tnet.Player owner = TNManager.GetPlayer(int ID);
how I can get some specific value from player "owner" ?
Logged
Elmo loves cookies
Jr. Member
Thank You
-Given: 60
-Receive: 1
Posts: 62
Re: Sync customProperties
«
Reply #1 on:
March 09, 2017, 05:43:10 AM »
or I can do that like this?
public
class
PlayerController
:
NetworkBehaviour
{
public
static
PlayerController GetPlayer
(
int
aID
)
{
GameObject
[
]
playerList
=
GameObject
.
FindGameObjectsWithTag
(
"Player"
)
;
for
(
int
i
=
0
;
i
<
playerList
.
Length
;
i
++
)
{
if
(
playerList
[
i
]
.
GetComponent
<
PlayerController
>
(
)
.
m_playerID
==
aID
)
{
return
playerList
[
i
]
.
GetComponent
<
PlayerController
>
(
)
;
}
}
return
null
;
}
//bla bla bla
}
and use PlayerController.GetPlayer(int aID) - for take Player`s custom Values
it is not good using always "GameObject.FindGameObjectsWithTag"?
Logged
cmifwdll
Global Moderator
Sr. Member
Thank You
-Given: 0
-Receive: 149
Posts: 285
TNet Alchemist
Re: Sync customProperties
«
Reply #2 on:
March 09, 2017, 09:21:43 AM »
public
class
PlayerController
{
public
int
ID
=
-
1
;
void
Start
(
)
{
ID
=
GameManager
.
Instance
.
RegisterPlayer
(
this
)
;
}
}
public
class
GameManager
{
public
static
GameManager Instance
;
List
<
PlayerController
>
_Players
=
new
List
<
PlayerController
>
(
)
;
void
Awake
(
)
{
if
(
Instance
!=
null
)
{
Destroy
(
this
.
gameObject
)
;
}
else
{
Instance
=
this
;
}
}
public
int
RegisterPlayer
(
PlayerController player
)
{
_Players
.
Add
(
player
)
;
return
_Players
.
Count
-
1
;
}
public
PlayerController GetPlayerByID
(
int
id
)
{
if
(
(
id
<
0
)
||
(
id
>=
_Players
.
Count
)
)
return
null
;
return
_Players
[
id
]
;
}
}
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
TNet 3 Support
»
Sync customProperties