-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSA_speed.cs
54 lines (43 loc) · 1.13 KB
/
SA_speed.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//[RequireComponent(typeof(Rigidbody2D))]
public class SA_speed : MonoBehaviour
{
// public AnimationCurve xCurve, yCurve;
private float timeElapsed = 0;
private bool started = false;
private Vector2 startPos;
public float speed = 20f;
public Rigidbody2D rb;
private void Awake()
{
rb = GetComponent<Rigidbody2D>();
}
/* private void FixedUpdate()
{
if (!started)
{
started = true;
timeElapsed = 0;
startPos = transform.position;
}
else
{
timeElapsed += Time.deltaTime;
rb.MovePosition(new Vector2(
startPos.x + xCurve.Evaluate(timeElapsed),
startPos.y + yCurve.Evaluate(timeElapsed))
);
}
}*/
// Start is called before the first frame update
void Start()
{
rb.velocity = transform.right * speed;
}
// Update is called once per frame
void Update()
{
}
}