public void FollowPath() { InitializaPath(); float distance = Vector3.Distance(finalPath[0], finalPath[finalPath.Length - 1]); rb.DOPath(finalPath, 1 / (projectileSpeed * 0.1f), pathType).SetEase(pathFollowEase).OnComplete(PathFinish).SetLoops(defaultLoopCount, defaultLoopType); // rb.DOPath(finalPath, 1 / projectileSpeed, pathType) .OnComplete(PathFinish); }
private void EnemyMovement() { for (int i = 0; i < EnemyPathTransforms.Count; i++) { EnemyPath[i] = EnemyPathTransforms[i].position; } EnemyBody.DOPath(EnemyPath, 2.5f, PathType.Linear, PathMode.Sidescroller2D).SetLoops(-1, LoopType.Yoyo).SetEase(Ease.Linear).OnStepComplete(() => { var enemyScale = gameObject.transform.localScale; enemyScale.x *= -1; gameObject.transform.localScale = enemyScale; }); }
public static TweenerCore <Vector3, Path, PathOptions> CreateDOTweenPathTween( MonoBehaviour target, bool tweenRigidbody, bool isLocal, Path path, float duration, PathMode pathMode ) { TweenerCore <Vector3, Path, PathOptions> t = null; bool rBodyFoundAndTweened = false; #if true// PHYSICS_MARKER if (tweenRigidbody) { Rigidbody rBody = target.GetComponent <Rigidbody>(); if (rBody != null) { rBodyFoundAndTweened = true; t = isLocal ? rBody.DOLocalPath(path, duration, pathMode) : rBody.DOPath(path, duration, pathMode); } } #endif #if true// PHYSICS2D_MARKER if (!rBodyFoundAndTweened && tweenRigidbody) { Rigidbody2D rBody2D = target.GetComponent <Rigidbody2D>(); if (rBody2D != null) { rBodyFoundAndTweened = true; t = isLocal ? rBody2D.DOLocalPath(path, duration, pathMode) : rBody2D.DOPath(path, duration, pathMode); } } #endif if (!rBodyFoundAndTweened) { t = isLocal ? target.transform.DOLocalPath(path, duration, pathMode) : target.transform.DOPath(path, duration, pathMode); } return(t); }
/// <summary> /// Setup the tween when setting tha path vectors /// </summary> private void InitPathTween() { // If there's an exisiting tween, kill if (_pathTween is object) { _pathTween.Kill(); } // NOTE: I can't do .SetLookAt to rotate the enemy because DOTween reported a casting error. // Seems like an internal bug. Use manual Update() instead. _pathTween = _rigidbody .DOPath(_path.ToArray(), _totalTimeRequired, PathType.Linear, PathMode.TopDown2D) .SetEase(Ease.Linear) .OnComplete(() => { _pathTween.Kill(); _pathTween = null; Die(true); }) .Pause(); }