Author Topic: Tnet new customer  (Read 5457 times)

Dasca

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Tnet new customer
« on: April 09, 2014, 11:39:19 AM »
Hi, Aren, Hi all,

I'm pretty new to Unity, just couple of month so sorry if I ask something stupid. I've just bought Tnet and MPGSK kit and I'm starting play with them, before try with TNET I've made a prototype with uLink (Auth Server) that was easy to understand from my point of view.

This is the problem: I'm trying to create a bullet... When the fire button was pressed I create a tnObject, there is a way from the bullet object to send damage message to objects near the explosion radius?

thx

Dasca
« Last Edit: April 09, 2014, 11:59:43 AM by Dasca »

djray2k

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 4
  • Posts: 74
  • Blockey Hockey!
    • View Profile
    • Walking Talking Grilling Bear Studios
Re: Tnet new customer
« Reply #1 on: April 09, 2014, 04:53:35 PM »
Send damage message to objects? I assume you mean other players. If thats the case:
  • Get a the list of players (objects) affected by the explosion
  • Call tno.Send to each of those players with the damage message

In general the hosting party should decide who gets damaged because of cheating issues, but it's OK for practice.

Dasca

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: Tnet new customer
« Reply #2 on: April 09, 2014, 06:29:54 PM »
Hi DjRay2K,

first of all thanks for your reply!

Yes, I mean others players.
When you said "Call tno.Send to each of those players with the damage message" you mean I can send message from a tnobject to others object just specify the correct id?
English is not my language as you can see :)
Just to see if I understand correctly...
I can Send (SetDamage) messages from a "bullet object" to, let say, "tank object"?

Dasca
« Last Edit: April 10, 2014, 04:06:22 AM by Dasca »

Dasca

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: Tnet new customer
« Reply #3 on: April 10, 2014, 05:40:05 AM »
Maybe I found a solution with a better search in the forum

this is the part in the bullet script
obj = object to damage
obj.GetComponent<TNObject>().Send("SetDamage", Target.All, obj.tno.ownerID, force);

this is the part in the tank
    [RFC]
   void SetDamage (int ownerID, float damage)
    {
        if(ownerID == tno.ownerID)
        AddDamage(damage);
    }

is this the right solution?

thx

Dasca

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tnet new customer
« Reply #4 on: April 10, 2014, 08:18:44 AM »
Yup, that's right.

djray2k

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 4
  • Posts: 74
  • Blockey Hockey!
    • View Profile
    • Walking Talking Grilling Bear Studios
Re: Tnet new customer
« Reply #5 on: April 10, 2014, 09:14:36 AM »
Ah ok. I was assuming you only wanted to send the message to the players getting hit by the explosion.

Dasca

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: Tnet new customer
« Reply #6 on: April 10, 2014, 09:22:40 AM »
you right djray2k infact I just change the code like this

check sphere collision size force etc...
foreach collider
check if is a vehicle
...
 Player tankPlayer = TNManager.GetPlayer(v.tno.ownerID);
 v.GetComponent<TNObject>().Send("SetDamage", tankPlayer, forceRadius);

I think this would be better because I just send info to the correct players involved in the blast area, am I right?

thx

Dasca

djray2k

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 4
  • Posts: 74
  • Blockey Hockey!
    • View Profile
    • Walking Talking Grilling Bear Studios
Re: Tnet new customer
« Reply #7 on: April 10, 2014, 09:37:05 AM »
I believe it is better because you're sending the information only to the players affected. I'd let ArenMook confirm this first though. I'm still learning how to use TNet, too. :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tnet new customer
« Reply #8 on: April 11, 2014, 07:57:24 AM »
That sends the RFC only to the player that owns the object. Assuming that's what you want, then yes that's fine.