Browse Source

Yeet handle script added to allow things to be yeeted

feature/RoundManager
MrJDunn 3 years ago
parent
commit
69a6155b99
5 changed files with 49 additions and 14 deletions
  1. BIN
      Assets/Scenes/Testing Scenes/YeetScene.unity
  2. +4
    -3
      Assets/Scripts/Behaviours/YeetController.cs
  3. +9
    -9
      Assets/Scripts/Player Scripts/PlayerInputController.cs
  4. +23
    -0
      Assets/YeetHandle.cs
  5. +11
    -0
      Assets/YeetHandle.cs.meta

BIN
Assets/Scenes/Testing Scenes/YeetScene.unity (Stored with Git LFS) View File

size 16523

+ 4
- 3
Assets/Scripts/Behaviours/YeetController.cs View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
public class YeetController : MonoBehaviour, IYeetable
public class YeetController : MonoBehaviour
{
public GameObject parent { get; set; }
@ -19,7 +19,6 @@ public class YeetController : MonoBehaviour, IYeetable
{
_child = child;
_child.transform.parent = parent.transform;
yeetState = YeetState.Held;
}
@ -27,6 +26,7 @@ public class YeetController : MonoBehaviour, IYeetable
{
_child.transform.parent = null;
_child.transform.rotation = parent.transform.rotation;
_child.GetComponent<Rigidbody>().velocity = _child.transform.forward * yeetVelocity;
yeetState = YeetState.Yeeting;
_time = yeetDuration;
}
@ -43,11 +43,12 @@ public class YeetController : MonoBehaviour, IYeetable
switch(yeetState)
{
case YeetState.Yeeting:
_child.transform.position += _child.transform.forward * yeetVelocity * Time.deltaTime;
//_child.transform.position += _child.transform.forward * yeetVelocity * Time.deltaTime;
_time -= Time.deltaTime;
if(_time <= 0f)
{
Debug.Log("YeetController.Update: Yeet finished");
yeetState = YeetState.Unheld;
}
break;

+ 9
- 9
Assets/Scripts/Player Scripts/PlayerInputController.cs View File

@ -30,8 +30,8 @@ public class PlayerInputController : MonoBehaviour
private YeetController m_yeetController;
public GameObject child;
public GameObject body;
private GameObject m_child;
private GameObject m_body;
private void Awake()
{
@ -39,7 +39,7 @@ public class PlayerInputController : MonoBehaviour
m_controller = GetComponent<CharacterController>();
m_yeetController = GetComponent<YeetController>();
body = this.gameObject;
m_body = this.gameObject;
}
@ -59,23 +59,23 @@ public class PlayerInputController : MonoBehaviour
private void OnTriggerEnter(Collider collider)
{
Debug.Log("Bang!");
child = collider.gameObject;
Debug.Log("PlayerInputController.OnTriggerEnter: arrived");
m_child = collider.gameObject;
}
private void OnTriggerExit(Collider collider)
{
child = null;
m_child = null;
}
private void OnYeet()
{
m_yeetController.parent = body;
m_yeetController.parent = m_body;
switch (m_yeetController.yeetState)
{
case YeetController.YeetState.Unheld:
if(child)
m_yeetController.Hold(child);
if(m_child)
m_yeetController.Hold(m_child);
// Grab nearest baby
break;
case YeetController.YeetState.Held:

+ 23
- 0
Assets/YeetHandle.cs View File

@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class YeetHandle : MonoBehaviour
{
private BoxCollider m_handleArea;
// Start is called before the first frame update
void Start()
{
m_handleArea = gameObject.AddComponent<BoxCollider>();
m_handleArea.isTrigger = true;
m_handleArea.size = new Vector3(2, 2, 2);
}
// Update is called once per frame
void Update()
{
}
}

+ 11
- 0
Assets/YeetHandle.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a18fca169b45e1642b530ee6dc555240
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Loading…
Cancel
Save