Hi everyone :)
I'm actually running some "experiment", mostly to learn c#/unity and i'm a bit lost...
I found on youtube and forum that it actualy possible to scale things by attaching a sphere to an ent'. Everythings seems fine until i tryed to scale a chicken : it firstly disappear so i add an FixedUpdate to my class to force repositioning unitl the sphere radius match its LerpRadius but the scaled chicken just died some second after.
After some search i found that everythings i scale has a different transform.position and NetworkPosition (NetworkPosition is always (0,~0, 0) ).
If someone could help me a bit with that, it would be great :D
Here is the class i attached to the ent i scale :
public class scaler: MonoBehaviour
{
public SphereEntity b; //ball
public BaseEntity s; //shpere
public Vector3 op; //oldPos
public BaseEntity rc; //Raycasted (from ChatCommand)
public void setup(BaseEntity ent)
{
rc = ent;
op = rc.transform.position;
s = GameManager.server.CreateEntity(
"assets/prefabs/visualization/sphere.prefab",
this.transform.position + new Vector3(0,1,0),
new Quaternion(0,0,0,0),
true
);
b = s.GetComponent<SphereEntity>();
b.lerpRadius = 5f;
b.lerpSpeed = 10f;
s.Spawn();
if(rc)
rc.SetParent(s, true,true);
else
Console.WriteLine("no RC");
}
private void Update()
{
if(rc && (b.lerpRadius != b.currentRadius))
{
rc.transform.position = op;
rc.TransformChanged();
rc.SendNetworkUpdate();
Console.WriteLine("POS :{1} NetPos : {0}", rc.GetNetworkPosition(), base.transform.position);
}
}
}