Browse Source

Merge branch 'develop' of https://git.joshuareason.com/Jam/GGJ_2021 into develop

develop
Ellie 3 years ago
parent
commit
ed09f131a8
2 changed files with 40 additions and 36 deletions
  1. +40
    -1
      Assets/Scripts/Behaviours/YeetController.cs
  2. +0
    -35
      Assets/Scripts/Player Scripts/PlayerInputController.cs

+ 40
- 1
Assets/Scripts/Behaviours/YeetController.cs View File

@ -15,6 +15,14 @@ public class YeetController : MonoBehaviour
private GameObject _child;
private float _time;
private GameObject m_child;
private GameObject m_body;
private void Awake()
{
m_body = this.gameObject;
}
public void Hold(GameObject child)
{
_child = child;
@ -26,7 +34,7 @@ public class YeetController : MonoBehaviour
{
_child.transform.parent = null;
_child.transform.rotation = parent.transform.rotation;
_child.GetComponent<Rigidbody>().velocity = _child.transform.forward * yeetVelocity;
_child.GetComponent<Rigidbody>().velocity = _child.transform.forward * yeetVelocity + _child.transform.up * yeetVelocity;
yeetState = YeetState.Yeeting;
_time = yeetDuration;
}
@ -59,4 +67,35 @@ public class YeetController : MonoBehaviour
break;
}
}
private void OnTriggerEnter(Collider collider)
{
Debug.Log("PlayerInputController.OnTriggerEnter: arrived");
m_child = collider.gameObject;
}
private void OnTriggerExit(Collider collider)
{
m_child = null;
}
private void OnYeet()
{
parent = m_body;
switch (yeetState)
{
case YeetController.YeetState.Unheld:
if(m_child)
Hold(m_child);
// Grab nearest baby
break;
case YeetController.YeetState.Held:
Yeet();
// Yeet baby
break;
case YeetController.YeetState.Yeeting:
// Cooldown?
break;
}
}
}

+ 0
- 35
Assets/Scripts/Player Scripts/PlayerInputController.cs View File

@ -30,16 +30,11 @@ public class PlayerInputController : MonoBehaviour
private YeetController m_yeetController;
private GameObject m_child;
private GameObject m_body;
private void Awake()
{
m_input = GetComponent<PlayerInput>();
m_controller = GetComponent<CharacterController>();
m_yeetController = GetComponent<YeetController>();
m_body = this.gameObject;
}
@ -57,36 +52,6 @@ public class PlayerInputController : MonoBehaviour
m_desiredDirection = new Vector3(m_recievedInput.x, 0.0f, m_recievedInput.y);
}
private void OnTriggerEnter(Collider collider)
{
Debug.Log("PlayerInputController.OnTriggerEnter: arrived");
m_child = collider.gameObject;
}
private void OnTriggerExit(Collider collider)
{
m_child = null;
}
private void OnYeet()
{
m_yeetController.parent = m_body;
switch (m_yeetController.yeetState)
{
case YeetController.YeetState.Unheld:
if(m_child)
m_yeetController.Hold(m_child);
// Grab nearest baby
break;
case YeetController.YeetState.Held:
m_yeetController.Yeet();
// Yeet baby
break;
case YeetController.YeetState.Yeeting:
// Cooldown?
break;
}
}
private void ApplyRotation()
{

Loading…
Cancel
Save