Exemplo n.º 1
0
    // 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);
    }
Exemplo n.º 2
0
    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;
    }
Exemplo n.º 3
0
 protected void Start()
 {
     DirVec = EndPos - gameObject.transform.position;
     DirVec.Normalize();
 }