-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJumpPad.cs
42 lines (30 loc) · 833 Bytes
/
JumpPad.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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class JumpPad : MonoBehaviour
{
public bool nowjump = false;
public bool _isPlayerInside;
public GameObject player;
public float jumpHeight =1.0f;
private void OnTriggerEnter(Collider other)
{
_isPlayerInside = true;
}
private void OnTriggerExit(Collider other)
{
_isPlayerInside = false;
}
private void LateUpdate()
{
Vector3 jump = player.transform.position;
if (_isPlayerInside && !nowjump)
{
player.transform.DOLocalMoveY(jump.y + jumpHeight, 1f).SetEase(Ease.OutQuad).SetRelative(true).OnComplete( () => nowjump =true );
}if(nowjump){
nowjump = false;
}
}
}