-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObstacleAnimation.cs
More file actions
46 lines (34 loc) · 1.22 KB
/
ObstacleAnimation.cs
File metadata and controls
46 lines (34 loc) · 1.22 KB
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
//障害物のアニメーションを制御するスクリプト
public class ObstacleAnimation : MonoBehaviour
{
private float ScaleAmount = 0.2f;
private float scaleTime = 0.1f;
private Vector3 scaleVector;
private Vector3 defaultScale;
private Sequence sequence;
private bool isPlaying = false;
// Start is called before the first frame update
void Start()
{
defaultScale = transform.localScale;
}
void OnTriggerEnter(Collider other)
{
//プレイヤーが自分(障害物)を通り過ぎたらアニメーションを開始する。
if (other.gameObject.CompareTag("Player") && !isPlaying)
{
isPlaying = true;
scaleVector = Vector3.one * ScaleAmount;
sequence = DOTween.Sequence();
sequence.Append(transform.DOScale(transform.localScale + scaleVector, scaleTime))
.Append(transform.DOScale(defaultScale, scaleTime))
.AppendCallback(() => isPlaying = false);
SoundManager.i.PlayOneShot(6, 1f);
Debug.Log("obstacle Scale");
}
}
}