-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMoveObjectIf.cs
39 lines (32 loc) · 1.02 KB
/
MoveObjectIf.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveObjectIf : MonoBehaviour
{
private QuestManager questManager;
public GameObject target;
private float speed = 2.0f;
// Start is called before the first frame update
void Start()
{
questManager = FindObjectOfType<QuestManager>();
}
private void OnCollisionStay2D(Collision2D collision)
{
if (collision.gameObject.tag.Equals("Player"))
{
if (questManager.quests[7].questCompleted &&
questManager.quests[8].questCompleted &&
questManager.quests[9].questCompleted &&
questManager.quests[10].questCompleted &&
questManager.quests[11].questCompleted)
{
MoveObjectTo();
}
}
}
void MoveObjectTo()
{
this.transform.position = Vector2.MoveTowards(this.transform.position, target.transform.position, speed* Time.fixedDeltaTime);
}
}