Unit.GoTo C# (CSharp) Method

GoTo() public method

public GoTo ( Vector3 target, bool isRunning ) : void
target Vector3
isRunning bool
return void
    public void GoTo(Vector3 target, bool isRunning)
    {
        // We're starting movement, so start the walking animation
        if (isRunning){
            running = true;
        } else {
            moving = true;
        }

        targetPosition = target;
        seeker.StartPath(transform.position, targetPosition, OnPathComplete);
    }

Usage Example

Example #1
0
        private IEnumerator Roam()
        {
            while (!target)
            {
                if (owner == null)
                {
                    yield return(null);
                }
                if (!IsOwnerTooFar())
                {
                    Unit nearestEnemy = AIUtils.GetNearestEnemy(_unit, agroRadius);
                    if (nearestEnemy == null)
                    {
                        nearestEnemy = AIUtils.GetNearestEnemy(owner, agroOwnerRadius);
                    }
                    if (nearestEnemy != null)
                    {
                        Attack(nearestEnemy);
                        yield break;
                    }
                }

                var newPosition = owner.iso.pos + _maintainOffset;
                _unit.GoTo(newPosition);
                yield return(new WaitForSeconds(Random.Range(0.1f, 0.5f)));
            }
        }
All Usage Examples Of Unit::GoTo