Browse Source

Yeeting with Josh's player manager

feature/RoundManager
MrJDunn 3 years ago
parent
commit
0b44273f1f
7 changed files with 69 additions and 13 deletions
  1. BIN
      Assets/Scenes/Testing Scenes/YeetScene.unity
  2. +5
    -5
      Assets/Scripts/Behaviours/YeetController.cs
  3. +22
    -1
      Assets/Scripts/Player Scripts/PlayerInputController.cs
  4. +30
    -0
      Assets/Settings/Input/PlayerControls.inputactions
  5. +1
    -1
      Packages/manifest.json
  6. +7
    -2
      Packages/packages-lock.json
  7. BIN
      ProjectSettings/PackageManagerSettings.asset

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

size 24219

+ 5
- 5
Assets/Scripts/Behaviours/YeetController.cs View File

@ -9,11 +9,11 @@ public class YeetController : MonoBehaviour, IYeetable
public float yeetVelocity = 10f;
public float yeetDuration = 2f;
private float time;
public enum YeetState { Unheld, Held, Yeeting };
public YeetState yeetState { get; private set; } = YeetState.Unheld;
private GameObject _child;
private float _time;
public void Hold(GameObject child)
{
@ -26,9 +26,9 @@ public class YeetController : MonoBehaviour, IYeetable
public void Yeet()
{
_child.transform.parent = null;
_child.transform.rotation = parent.transform.rotation;
yeetState = YeetState.Yeeting;
time = yeetDuration;
_time = yeetDuration;
}
// Start is called before the first frame update
@ -44,9 +44,9 @@ public class YeetController : MonoBehaviour, IYeetable
{
case YeetState.Yeeting:
_child.transform.position += _child.transform.forward * yeetVelocity * Time.deltaTime;
time -= Time.deltaTime;
_time -= Time.deltaTime;
if(time <= 0f)
if(_time <= 0f)
{
yeetState = YeetState.Unheld;
}

+ 22
- 1
Assets/Scripts/Player Scripts/PlayerInputController.cs View File

@ -28,13 +28,16 @@ public class PlayerInputController : MonoBehaviour
private Vector3 m_desiredDirection;
private bool m_recievedInput => m_desiredDirection.magnitude != 0;
private YeetController m_yeetController;
public GameObject testChild;
public GameObject body;
private void Awake()
{
m_input = GetComponent<PlayerInput>();
m_controller = GetComponent<CharacterController>();
m_yeetController = GetComponent<YeetController>();
}
@ -51,6 +54,24 @@ public class PlayerInputController : MonoBehaviour
m_desiredDirection = new Vector3(m_recievedInput.x, 0.0f, m_recievedInput.y);
}
private void OnYeet()
{
m_yeetController.parent = body;
switch (m_yeetController.yeetState)
{
case YeetController.YeetState.Unheld:
m_yeetController.Hold(testChild);
// Grab nearest baby
break;
case YeetController.YeetState.Held:
m_yeetController.Yeet();
// Yeet baby
break;
case YeetController.YeetState.Yeeting:
// Cooldown?
break;
}
}
private void ApplyRotation()
{

+ 30
- 0
Assets/Settings/Input/PlayerControls.inputactions View File

@ -12,6 +12,14 @@
"expectedControlType": "Vector2",
"processors": "",
"interactions": ""
},
{
"name": "Yeet",
"type": "Button",
"id": "23ebbd64-55ef-42f7-9f88-d2ea6b5f9677",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
}
],
"bindings": [
@ -135,6 +143,28 @@
"action": "Movement",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "e7da0e69-0039-470a-bf8f-079ca8b3c3d6",
"path": "<Gamepad>/buttonSouth",
"interactions": "",
"processors": "",
"groups": "",
"action": "Yeet",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "21a02656-d443-4954-a0f5-6fc8b87f7107",
"path": "<Keyboard>/space",
"interactions": "",
"processors": "",
"groups": "",
"action": "Yeet",
"isComposite": false,
"isPartOfComposite": false
}
]
}

+ 1
- 1
Packages/manifest.json View File

@ -10,7 +10,7 @@
"com.unity.render-pipelines.universal": "8.3.1",
"com.unity.test-framework": "1.1.19",
"com.unity.textmeshpro": "3.0.1",
"com.unity.timeline": "1.3.6",
"com.unity.timeline": "1.3.7",
"com.unity.ugui": "1.0.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",

+ 7
- 2
Packages/packages-lock.json View File

@ -124,10 +124,15 @@
"url": "https://packages.unity.com"
},
"com.unity.timeline": {
"version": "1.3.6",
"version": "1.3.7",
"depth": 0,
"source": "registry",
"dependencies": {},
"dependencies": {
"com.unity.modules.director": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.ugui": {

BIN
ProjectSettings/PackageManagerSettings.asset (Stored with Git LFS) View File

size 1335

Loading…
Cancel
Save