// Update is called once per frame void Update() { if (CMapGenerator.bTool) { return; } if (Vector3.Distance(gameObject.transform.position, GoalPos) < 0.1f) { if (GoalPos == DefaultGoalPos) { DirVec = DefaultPos - DefaultGoalPos; DirVec.Normalize(); GoalPos = DefaultPos; } else { DirVec = DefaultGoalPos - DefaultPos; DirVec.Normalize(); GoalPos = DefaultGoalPos; } } gameObject.transform.Translate(DirVec * Time.deltaTime * Speed, Space.World); }
public override void Read(ref BinaryReader binaryReader) { base.Read(ref binaryReader); DefaultGoalPos.x = binaryReader.ReadSingle(); DefaultGoalPos.y = binaryReader.ReadSingle(); DefaultGoalPos.z = DefaultPosZ; Speed = binaryReader.ReadSingle(); DefaultPos = gameObject.transform.position; DirVec = DefaultGoalPos - DefaultPos; DirVec.Normalize(); GoalPos = DefaultGoalPos; }
protected void Start() { DirVec = EndPos - gameObject.transform.position; DirVec.Normalize(); }