当前位置:网站首页>Specific use examples of dotweenpath
Specific use examples of dotweenpath
2022-07-22 03:19:00 【Dongfang kuaidi】
Catalog
Path Editor Options: Track editing parameters , No introduction
ResetPath: Reset track Events:
WayPoints: Moving trajectory points
2.DoTween Pro Medium motion trajectory (DoTween Path) How to become relative motion
3. Code dynamically adds points
1. Basic properties
Scene View Commands
(1)SHIFT+CTRL:add a waypoint Add a track point
(2)SHIFT+ALT:remove a waypoint Remove a track point
INfo
(1)Path Length: Track length
Tween Options
(1)AutoPlay: Auto play
(2)AutoKill: Automatically destroy the animation after playing
(3)Duration: Animation duration
SpeedBased:If selected ,the duration will count as units/degreex second; If selected , This time is taken as the unit time .
(4)Delay: Time delay
(5)Ease: This is an enumeration , It can be understood as the animation playback rate curve
(6)Loops: cycles , The number of animation cycles
-1: Express Cycle all the time
0: Means to play only once
When it's worth >1 when , The inspector panel appears LoopType, As the name suggests, it refers to the loop type :
Restart: restart , Later animation cycle playback will restart from the starting point ;
Yoyo: Play back and forth
Incremental: To increase the , hinder path The mobile animation will be played based on the end of the previous cycle
(7)ID: Animation ID
(8)UpdateType: This enumeration has three values , Refers to the update type
Normal: Normal update ,Update()
Late: Update later ,LateUpdate()
Fixed: Fixed update ,FixedUpdate()
Path Tween Options
(1)Path Type: Track line type
Linear: Linear
Catmull Rom: curve
(2)Close Path: Closed curves , Connect the start point and the end point
(3)Lock Rotation: Lock rotation ,xyzw
Path Editor Options: Track editing parameters , No introduction
ResetPath: Reset track
Events:
(1)OnStart: At the beginning of the
(2)OnPlay: When the play
(3)OnUpdate: update
(4)OnStep: When completed in one step
(5)OnComplete: When finished
(6)OnCreated: When creating animation
The sequence of events is :OnCreated->OnStart->OnPlay->OnUpdate( Has been performed , Until completion ), Execute when the animation is completed in one step OnStep, Execute after the whole animation OnComplete
WayPoints: Moving trajectory points
The one on the right Copy to clipboard, Copy coordinates to clipboard
The plus / minus button means to increase or decrease coordinate points
DOPath

DOLocalPath
2.DoTween Pro Medium motion trajectory (DoTween Path) How to become relative motion
- When declaring a type, you must declare the type DOTweenPath( Do not use Tween), because DORestart It can only be used for DOTweenPath and DOTweenAnimation.
- Generally, the trajectory is fixed . however —— Here is a but , If you Restart after , It will be based on its current location , Regenerate path , This solves the problem we mentioned above
- The trajectory is the world coordinate , stay unity Checked in the editor (relative) relative motion , Only valid in the editor ?
3. Code dynamically adds points
public Vector3[] vector3s;
public Transform[] targets;
public Transform earth;
private void Awake()
{
for (int i = 0; i < targets.Length; i++)
{
vector3s[i] = new Vector3(targets[i].position.x, targets[i].position.y, targets[i].position.z);
}
}
private void Start()
{
earth.DOPath(vector3s, 50, PathType.Linear).SetEase(Ease.Linear).SetLoops(-1);
}
4.ex
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices.WindowsRuntime;
using DG.Tweening;
using DG.Tweening.Plugins.Core.PathCore;
using UnityEngine;
public class DomoveSimpleScript : MonoBehaviour
{
//public Ease m_MoveType = Ease.Linear;
public float m_Speed = 5f;
public float m_CheckTime = 1f;
private List<Vector3> m_PointList;
private Action mf_Complete;
void Awake()
{
if (m_PointList==null)
{
m_PointList=new List<Vector3>();
}
}
// Add the required path point information
public void AddWayPoint(Vector3 V)
{
if (m_PointList==null)
{
m_PointList=new List<Vector3>();
}
m_PointList.Add(V);
}
//
public void DoMove(float Spd=1.0f,Action F=null,Action stepFunc=null,Ease moveType = Ease.Linear)
{
m_Speed = Spd;
// Callback after path completion
mf_Complete = F;
if (m_PointList!=null)
{
var doAni= transform.DOPath(m_PointList.ToArray(), m_Speed);
doAni.SetEase(moveType);
// Default orientation
doAni.SetLookAt(0);
doAni.OnWaypointChange(
(s) =>
{
//Debug.LogError(s);
// Callback after single step
stepFunc();
});
doAni.OnComplete(OnComplete);
m_isStop = false;
}
}
public bool IsMoving()
{
return (!m_isStop);
}
private float Dtime = 0f;
private bool m_isStop = true;
private void Update()
{
if (m_isStop)
return;
Dtime += Time.deltaTime;
if (Dtime > m_CheckTime)
{
Dtime = 0;
}
}
void OnComplete()
{
m_isStop = true;
m_PointList.Clear();
if (mf_Complete!=null)
{
mf_Complete();
}
}
}
边栏推荐
猜你喜欢
随机推荐
Self defined multiple code of station B
3分钟掌握hook在typescript中的姿势
关于res目录下图片引起的OOM解决方法
filebeat自动关闭解决
怎样才能让需求无法如期顺利上线(四)集成测试阶段
ELF 格式详解(一)
《如果……》拉迪亚德·吉卜林
DoTweenPath的具体使用实例
CodeQL使用流程
anaconda安装Labelimg(超简单可用)
Mathematical angles, radians and trigonometric functions in the game
Tips for using efficient development tools
Go process string to legal file name
list集合根据对象属性去重
Day 6(数组例题)
Base64 encryption and decryption
阅读笔记:《You Only Look Once:Unified,Real-time Object Detection》
怎样才能让需求无法如期顺利上线(一)整体策略
【 JS Reverse 100 examples】 Reverse Analysis of Announcement URL Parameters in a Public Resource Trading Network
jdbc 02: 连接mysql,并实现删除与更新