but it is not work. Can someone please give me working code or some very simple example how to use RFC? Thanks for answer.
Title: Re: RFC question
Post by: Suvu on February 18, 2013, 10:33:53 AM
Hey matis!
It doesn't work because you're sending a transform and then not applying it back to the gameObject, If you just want to change the objects scale, try this instead :
void Start ()
{
test_transform.parent= cube_gen.transform.parent;//Set the parent if needed
if(TNManager.isHosting)// Only send the new scale if you are the host (or you could use TNManager.isThisMyObject but that needs to be checked on Awake!)
{
TNObject test = GetComponent <TNObject>();
test.Send("SetScale", Target.AllSaved, new Vector3(0.5f, 0.5f, 0.5f));
}
}
[RFC]
void SetScale (Vector3 scale)
{
gameObject.transform.localScale= scale;// apply the scale back to the gameObject
}
Hope that helps!
Title: Re: RFC question
Post by: matis on February 18, 2013, 10:39:37 AM
Hi, thanks it is works great. Can you please show me code also for that parenting - for better understand RFC?
EDIT: Can any one please show how to call RFC for this code?
Can't you just put that code inside an RFC, like you had it in your first example?
Title: Re: RFC question
Post by: matis on February 19, 2013, 06:25:11 AM
oh:) it is "work" - problem is some of objects are placed not to correct position but I will figure that out. Thanks btw why is that working? My .Send ("SetScale", Target.AllSaved, new Vector3(0.5f, 0.5f, 0.5f)); saying just new Vector3 nothing about transform,...
one problem what I founded - client have different terrain objects as a host. terrain is created by that RFC
Title: Re: RFC question
Post by: ArenMook on February 19, 2013, 08:03:06 PM
Simple rules to follow: 1. If you used Instantiate, change it to TNManager.Create. 2. If you called a function directly to do something and you want it to work on all clients, replace it with an RFC call. 3. Only the TNManager.isHosting client should be calling RFCs that do stuff. 4. Never modify local variables. Always do an RFC call to modify variables.
Follow these simple rules, and everything will work correctly.
To illustrate #4 in greater detail -- do not do this:
transform.position= Vector3.zero;// This is wrong!