Exemplo n.º 1
0
    void Update()
    {
        if (pathCreator != null && move)
        {
            distanceTravelled += speed * Time.deltaTime;
            transform.position = pathCreator.path.GetPointAtDistance(distanceTravelled, endOfPathInstruction);
            transform.position = new Vector3(transform.position.x + offsetPosition.x,
                                             transform.position.y + offsetPosition.y,
                                             transform.position.z + offsetPosition.z);

            normalRotation = pathCreator.path.GetRotationAtDistance(distanceTravelled, endOfPathInstruction);
            //Debug.Log("Rotation Previouse: " + transform.rotation);

            //transform.rotation = new Quaternion(transform.rotation.x, transform.rotation.z, transform.rotation.y, transform.rotation.w);
            transform.rotation = new Quaternion(normalRotation.x + offsetRotation.x,
                                                normalRotation.y + offsetRotation.y,
                                                normalRotation.z + offsetRotation.z,
                                                normalRotation.w + offsetRotation.w);

            if (distanceTravelled >= pathCreator.path.length)
            {
                //ENd
                end.Emit(true);
            }
        }
    }