My Tower Defence -- Smooth Movement and more accurate timing for SFX

The code for smooth movement:

 if (current < xpath.Count)
        {
            if (transform.position != xpath[current].transform.position)
            {
                Vector3 pos = Vector3.MoveTowards(transform.position, xpath[current].transform.position, speed * Time.deltaTime);
                GetComponent<Rigidbody>().MovePosition(pos);
            }
            else
            {
                if (current < xpath.Count)
                {
                    current = current + 1;
                }
                print(current);

            }
        }
        else if (transform.position == xpath[xpath.Count-1].transform.position)
        {
            SelfDestruct();
        }
1 Like

Thank you for posting this! :grin:

Privacy & Terms