-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWave.cs
More file actions
38 lines (33 loc) · 832 Bytes
/
Wave.cs
File metadata and controls
38 lines (33 loc) · 832 Bytes
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Wave: MonoBehaviour
{
Rigidbody2D rb;
[SerializeField]
private float speed;
public GameObject target;
public GameObject position;
public float tt = 1;
private float dir;
// Update is called once per frame
private void Start()
{
transform.position = position.transform.position;
dir = target.transform.localScale.x;
//transform.gameObject.SetActive(true);
}
void Update()
{
transform.position += new Vector3(dir * speed * Time.deltaTime, 0, 0);
tt -= Time.deltaTime;
if (tt <= 0)
{
destroy();
}
}
public void destroy()
{
Destroy(gameObject);
}
}