-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1311738
commit 190bdc0
Showing
9 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# HW3: Hands and Physics Game | ||
Following are the requirements for the assignment, parts from either could be completed. | ||
|
||
## Part 1 - Hands | ||
|
||
Basic Rigged hands (20p) | ||
Finger Colliders (30p) | ||
|
||
## Part 2 - A Game with Physics Interaction | ||
|
||
Physics interaction (40p) | ||
Objective (30p) | ||
Theme(20p) | ||
|
||
## My submitted assignment | ||
|
||
I have made a box packaging factory. This could be used during the onboarding session of new employees coming to work in that factory & will get trained on somethin similar to my project. | ||
|
||
Basic hands with finger colliders is used by the VR user. They have to physically interact with the start and stop button of the conveyer belt as well as the packaging lever. The objective is to pack the given box under the packager. The theme includes various boxes in loading and unloading area fits the theme of a factory | ||
|
||
Instructions to perform tasks are present on the walls. | ||
|
||
![Video for HW3](HW3.gif) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// using System.Collections; | ||
// using System.Collections.Generic; | ||
// using UnityEngine; | ||
|
||
// public class BoxPackage : MonoBehaviour | ||
// { | ||
// public Material PackagedMat; | ||
// private Transform endpoint; | ||
|
||
// public void ChangeColorPosition(){ | ||
// PackageMat.color = new Color (195, 87, 80); | ||
// endpoint.position = new Vector(0,0.75, 1.174); | ||
// } | ||
|
||
// void OnTriggerStay(Collider other){ | ||
// if (other.gameObject.tag == "PackageArea"){ | ||
// GetComponent<Renderer>.color = PackagedMat.color; | ||
// tranform.position = endpoint.position; | ||
// } | ||
|
||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class FactoryEntry : MonoBehaviour | ||
{ | ||
// public GameObject EntryPlace; | ||
|
||
void OnTriggerStay(Collider other){ | ||
// Debug.Log("Welcome to the Packaging Factory!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class HandPresencePhysics : MonoBehaviour | ||
{ | ||
public Transform target; | ||
private Rigidbody rb; | ||
|
||
void Start() | ||
{ | ||
rb = GetComponent<Rigidbody>(); | ||
} | ||
|
||
// Update is called once per frame | ||
void FixedUpdate() | ||
{ | ||
// Position | ||
rb.velocity = (target.position - transform.position)/Time.fixedDeltaTime; | ||
// Rotation | ||
Quaternion rotationDifference = target.rotation * Quaternion.Inverse(transform.rotation); | ||
rotationDifference.ToAngleAxis(out float angleInDegree, out Vector3 rotationAxis); | ||
|
||
Vector3 rotationDifferenceInDegree = angleInDegree * rotationAxis; | ||
|
||
rb.angularVelocity = (rotationDifferenceInDegree * Mathf.Deg2Rad / Time.fixedDeltaTime ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class MoveCube : MonoBehaviour | ||
{ | ||
public Transform Lever; | ||
private Vector3 offset; | ||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
// posCube = tranform.position.y; | ||
offset = this.transform.position; | ||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
// new Vector3 posCube += Lever.rotation.z; | ||
float z = Lever.transform.rotation.z; | ||
|
||
float transformY = -((z/12f) * 45f); | ||
|
||
|
||
this.transform.position = new Vector3(offset.x, transformY+offset.y, offset.z); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.Events; | ||
using System; | ||
|
||
public class PhysicsButton : MonoBehaviour | ||
{ | ||
[SerializeField] private float threshold = .1f; // The amount pressed to activate the button | ||
[SerializeField] private float deadZone = .025f; // prevent any bouncyness of the button.. press and releaase the button the whole time | ||
|
||
private bool _isPressed; // keep track if the button is already pressed and not send onPressed event again and again; state management | ||
private Vector3 _startPos; // compare the start position to the current position | ||
private ConfigurableJoint _joint; // joint and get the linear limit from there | ||
|
||
public UnityEvent onPressed, onReleased; | ||
|
||
void Start() | ||
{ | ||
_startPos = transform.localPosition; | ||
_joint = GetComponent<ConfigurableJoint>(); | ||
} | ||
|
||
void Update() | ||
{ | ||
if (!_isPressed && GetValue() + threshold >= 1) | ||
Pressed(); | ||
if(_isPressed && GetValue() - threshold <= 0) | ||
Released(); | ||
} | ||
|
||
private float GetValue(){ | ||
var value = Vector3.Distance(_startPos, transform.localPosition)/_joint.linearLimit.limit; | ||
|
||
if(Math.Abs(value) < deadZone){ | ||
value = 0; | ||
} | ||
return Mathf.Clamp(value, -1f, 1f); | ||
} | ||
private void Pressed(){ | ||
_isPressed = true; | ||
onPressed.Invoke(); | ||
Debug.Log("Pressed"); | ||
} | ||
|
||
private void Released(){ | ||
_isPressed = false; | ||
onReleased.Invoke(); | ||
Debug.Log("Released"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class conveyerBelt : MonoBehaviour | ||
{ | ||
public GameObject belt; | ||
public Transform endpoint; | ||
public float speed = 0; | ||
|
||
public void switchOn(){ | ||
speed = 0.5f; | ||
} | ||
|
||
public void switchOff(){ | ||
speed = 0f; | ||
} | ||
|
||
void OnTriggerStay(Collider other){ | ||
other.transform.position = Vector3.MoveTowards(other.transform.position, endpoint.position, speed * Time.deltaTime); | ||
// StartCoroutine(DelayBelt()); | ||
} | ||
|
||
// IEnumerator DelayBelt(){ | ||
// yield return new WaitForSeconds(100); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class packBox : MonoBehaviour | ||
{ | ||
public GameObject Box; | ||
public Material PackagedMat; | ||
public Transform endpoint; | ||
public float delay; | ||
|
||
void OnTriggerEnter(Collider other){ | ||
|
||
if (other.gameObject.tag == "Packager"){ | ||
Box.GetComponent<Renderer>().material = PackagedMat; | ||
StartCoroutine(DelayPack()); | ||
} | ||
} | ||
|
||
IEnumerator DelayPack(){ | ||
yield return new WaitForSeconds(delay); | ||
// Debug.Log("Delaying 3 seconds"); | ||
Box.transform.position = endpoint.position; | ||
} | ||
} |