Browse Source

Basic picking up and yeeting

jeff
MrJDunn 3 years ago
parent
commit
7765ee9a59
12 changed files with 199 additions and 2 deletions
  1. BIN
      Assets/Scenes/Testing Scenes/YeetScene.unity
  2. +7
    -0
      Assets/Scenes/Testing Scenes/YeetScene.unity.meta
  3. +8
    -0
      Assets/Scripts/Behaviours.meta
  4. +9
    -0
      Assets/Scripts/Behaviours/IYeetable.cs
  5. +11
    -0
      Assets/Scripts/Behaviours/IYeetable.cs.meta
  6. +61
    -0
      Assets/Scripts/Behaviours/YeetController.cs
  7. +11
    -0
      Assets/Scripts/Behaviours/YeetController.cs.meta
  8. +8
    -0
      Assets/Scripts/Player.meta
  9. +65
    -0
      Assets/Scripts/Player/ControllerBase.cs
  10. +11
    -0
      Assets/Scripts/Player/ControllerBase.cs.meta
  11. BIN
      ProjectSettings/InputManager.asset
  12. BIN
      ProjectSettings/TimelineSettings.asset

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

size 24778

+ 7
- 0
Assets/Scenes/Testing Scenes/YeetScene.unity.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7d479bacc53922e4498008816aade241
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 8
- 0
Assets/Scripts/Behaviours.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 408c7b3fd4c3afc4c9187c4ad234f2f2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
Assets/Scripts/Behaviours/IYeetable.cs View File

@ -0,0 +1,9 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public interface IYeetable
{
void Hold(GameObject child);
void Yeet();
}

+ 11
- 0
Assets/Scripts/Behaviours/IYeetable.cs.meta View File

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

+ 61
- 0
Assets/Scripts/Behaviours/YeetController.cs View File

@ -0,0 +1,61 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class YeetController : MonoBehaviour, IYeetable
{
public GameObject parent { get; set; }
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;
public void Hold(GameObject child)
{
_child = child;
_child.transform.parent = parent.transform;
yeetState = YeetState.Held;
}
public void Yeet()
{
_child.transform.parent = null;
yeetState = YeetState.Yeeting;
time = yeetDuration;
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
switch(yeetState)
{
case YeetState.Yeeting:
_child.transform.position += _child.transform.forward * yeetVelocity * Time.deltaTime;
time -= Time.deltaTime;
if(time <= 0f)
{
yeetState = YeetState.Unheld;
}
break;
case YeetState.Held:
break;
case YeetState.Unheld:
_child = null;
break;
}
}
}

+ 11
- 0
Assets/Scripts/Behaviours/YeetController.cs.meta View File

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

+ 8
- 0
Assets/Scripts/Player.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0899cb5e9885fc441bc2cfd3746b0ed9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 65
- 0
Assets/Scripts/Player/ControllerBase.cs View File

@ -0,0 +1,65 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ControllerBase : MonoBehaviour
{
public CharacterController characterController;
public float speed = 6f;
public float sensitivity = 10f;
public GameObject body;
public GameObject testChild;
public YeetController yeetController;
void Start()
{
}
// Update is called once per frame
void Update()
{
Move();
//Rotate();
if(Input.GetButtonDown("Fire1"))
{
yeetController.parent = body;
switch(yeetController.yeetState)
{
case YeetController.YeetState.Unheld:
yeetController.Hold(testChild);
// Grab nearest baby
break;
case YeetController.YeetState.Held:
yeetController.Yeet();
// Yeet baby
break;
case YeetController.YeetState.Yeeting:
// Cooldown?
break;
}
}
}
void Move()
{
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
Vector3 move = transform.forward * vertical + transform.right * horizontal;
characterController.Move(speed * Time.deltaTime * move);
}
void Rotate()
{
float horizontal = Input.GetAxis("Mouse Y");
body.transform.Rotate(0, horizontal * sensitivity, 0);
}
}

+ 11
- 0
Assets/Scripts/Player/ControllerBase.cs.meta View File

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

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

size 9731

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

size 411

Loading…
Cancel
Save