-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPushableItemContainer.cs
35 lines (29 loc) · 998 Bytes
/
PushableItemContainer.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// A special item container class that can be pushed around by characters.
/// </summary>
public class PushableItemContainer : ItemContainer {
private bool beingHeld = false;
private Transform originalParent = null;
public override void InteractStart(PlayerInput player) {
beingHeld = !beingHeld;
if (beingHeld) {
player.Movement.Stop();
player.Movement.RotationEnabled = false;
player.Hands.PickUpAndDropEnabled = false;
originalParent = transform.parent;
transform.SetParent(player.transform, true);
transform.rotation = Quaternion.identity;
} else {
transform.SetParent(originalParent, true);
player.Movement.RotationEnabled = true;
player.Hands.PickUpAndDropEnabled = true;
player.Hands.OnTriggerExit(GetComponent<Collider>());
}
}
public override void InteractStop(PlayerInput player) {
return;
}
}