add shovel and digging, basic item interaction
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
public class PlayerController : MonoBehaviour
|
||||
{
|
||||
public GameObject DougBody;
|
||||
public Shovel Shovel;
|
||||
public float walkSpeed;
|
||||
|
||||
Interactable nearestInteractable;
|
||||
@@ -10,7 +11,7 @@ public class PlayerController : MonoBehaviour
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -19,6 +20,7 @@ void Update()
|
||||
RotatePlayerTowardMouse();
|
||||
Walk();
|
||||
TryInteract();
|
||||
DigDetector();
|
||||
}
|
||||
|
||||
void Walk()
|
||||
@@ -27,6 +29,14 @@ void Walk()
|
||||
transform.position += DougBody.transform.right * Input.GetAxis("Horizontal") * walkSpeed * Time.deltaTime;
|
||||
}
|
||||
|
||||
void DigDetector()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Shovel.Dig();
|
||||
}
|
||||
}
|
||||
|
||||
void RotatePlayerTowardMouse()
|
||||
{
|
||||
Vector2 positionOnScreen = Camera.main.WorldToViewportPoint(DougBody.transform.position);
|
||||
|
||||
Reference in New Issue
Block a user