当前位置:网站首页>unity2D 箭头动画
unity2D 箭头动画
2022-07-21 19:52:00 【james-lx】
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
public int speed = 50;
public float zoomspeed = 0.002f;
public Vector2 v = new Vector2();
public List<Vector2> theWayPoints = new List<Vector2>();
public int index = 0;
public Vector3 v_a = new Vector3();
void Start()
{
// transform.Rotate(0, 0, 90f, Space.Self);
Vector2 p = transform.position;
p.x = 80;
p.y = 430;
transform.position = p;
Vector2 pos = transform.position;
pos.x = 350;
pos.y = 170;
theWayPoints.Add(pos);
pos.x = 600;
pos.y = 223;
theWayPoints.Add(pos);
pos.x = 800;
pos.y = 500;
theWayPoints.Add(pos);
pos.x = 800;
pos.y = 500;
theWayPoints.Add(pos);
}
// Update is called once per frame
void Update()
{
transform.position = Vector2.MoveTowards(transform.position, theWayPoints[index], speed * Time.deltaTime); //箭头指向
v_a = Vector2.right;
transform.localScale += v_a * zoomspeed * Time.deltaTime; //向右放大
Debug.Log(Time.deltaTime.ToString());
if (transform.position.Equals(theWayPoints[index])) //如果到了下一个点
{
index++;
transform.localScale = Vector2.one;
// ((RectTransform)transform).sizeDelta = new Vector2(100, 100); ;
}
else //在一个点内的动作
{
Vector2 v = (theWayPoints[index] - (Vector2)transform.position).normalized * speed;//向右移动
transform.right = v;
}
}
}
边栏推荐
猜你喜欢
BigDecimal精度的哪些坑
C. Doremy‘s IQ(贪心)
[cloud native | learn kubernetes from scratch] VII. Resource list and namespace
Dynamically add and modify the appender of logback (to dynamically adjust the log level and appender parameters)
窗口函数的5种方法总结
doccano数据标注平台使用
[unity3d] blood bar (HP)
Pango logos dual boot
What is a video content recommendation engine?
工作任务“杂乱难”?这个小工具帮你轻松搞定!
随机推荐
"Messy and difficult" work tasks? This gadget will help you get it done easily!
Request 和Response 说明
What is the fastapi asynchronous framework? (comprehensive understanding)
C. Doremy‘s IQ(贪心)
Request and response description
mysql
MySQL:字符集与比较规则
机房动环监控系统的功能,动环监控系统的主要功能
doccano数据标注平台使用
How to choose the appropriate data type for fields in MySQL?
史上最全的mysql数据类型汇总(下)
GL_ TRIANGLE_ Fan and GL_ TRIANGLE_ STRIP
Etcdv3 practice · common operation model encapsulation and detailed implementation
Response response byte data
Servlet garbled code solution
The most complete summary of MySQL data types in history - (first)
Is it safe to buy funds on e fund? I want to make a fixed investment in the fund
unordered_map的使用
How to get the Apache official domain name mailbox? Exclusive interview with five new committers of Apache linkis
如何高效Debug(又名如何高效解决问题)