-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttackMovement
More file actions
40 lines (33 loc) · 922 Bytes
/
Copy pathAttackMovement
File metadata and controls
40 lines (33 loc) · 922 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
39
40
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AttackMovement : MonoBehaviour
{
private Vector3 movement = new Vector3(1, 0, 0);
private float speed = 10f;
private float duration = 0.15f;
private float timeRemaining = 0;
private GameObject player;
// Start is called before the first frame update
void Start()
{
player = GameObject.Find("Player");
timeRemaining = duration;
}
// Update is called once per frame
void Update()
{
//timer to control duration of attack
if (timeRemaining <= 0)
{
player.GetComponent<PlayerController>().isAttacking = false;
Destroy(gameObject);
}
else
{
timeRemaining -= Time.deltaTime;
}
//move downwards
transform.Translate(movement * speed * Time.deltaTime);
}
}