update
This commit is contained in:
@@ -23,6 +23,7 @@ public class NetworkTrail : NetworkBehaviour
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
public float trailLength;
|
||||
void Update()
|
||||
{
|
||||
if(isServer){
|
||||
@@ -32,9 +33,25 @@ public class NetworkTrail : NetworkBehaviour
|
||||
}else{
|
||||
|
||||
}
|
||||
trailLength = GetTrailLength();
|
||||
// Debug.Log(GetTrailLength());
|
||||
}
|
||||
|
||||
public float GetTrailLength(){
|
||||
Vector3[] m_positions = new Vector3[trail.positionCount];
|
||||
trail.GetPositions(m_positions);
|
||||
if(m_positions.Length < 2){
|
||||
Debug.Log("Trail is empty?");
|
||||
return 0;
|
||||
}
|
||||
|
||||
float distance = 0;
|
||||
for(int i = 1; i < m_positions.Length;i++){
|
||||
distance += Vector2.Distance(m_positions[i-1], m_positions[i]);
|
||||
}
|
||||
|
||||
return distance;
|
||||
}
|
||||
[ClientRpc]
|
||||
void RpcUpdatePositions(Vector3[] Positions){
|
||||
if(!enableValidation){return;}
|
||||
|
||||
Reference in New Issue
Block a user