Add basic breakout to scene

This commit is contained in:
Toomas Tamm
2021-03-08 15:44:45 +02:00
parent 14cb8f42df
commit 1db89a45b0
39 changed files with 6385 additions and 106995 deletions

View File

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

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EndForcefield : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

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

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class KinematicSpeedTransfer : MonoBehaviour
{
public float amplification = 1f;
private Vector3 _oldPosition;
private Vector3 _velocity;
// Start is called before the first frame update
void Start()
{
_oldPosition = transform.position;
_velocity = Vector3.zero;
}
// Update is called once per frame
void Update()
{
Vector3 newPosition = transform.position;
Vector3 posDiff = newPosition - _oldPosition;
_velocity = posDiff / Time.deltaTime;
_oldPosition = newPosition;
}
private void OnCollisionEnter(Collision other)
{
if (other.rigidbody.isKinematic) return;
other.rigidbody.AddRelativeForce(_velocity * amplification, ForceMode.Impulse);
}
}

View File

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

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
public class OffsetOnDirectHit : MonoBehaviour
{
public float minAngle = 0;
public float maxAngle = 20;
private Rigidbody _rigidbody;
private void Start()
{
_rigidbody = new Rigidbody();
}
private void OnCollisionEnter(Collision other)
{
Vector3 normal = other.contacts[0].normal;
Vector3 velocity = _rigidbody.velocity;
// Get Angle
float angle = Vector3.Angle(velocity, -normal);
if (angle > minAngle & angle < maxAngle)
{
// Add random torque to randomize direction
_rigidbody.AddTorque(new Vector3(Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f)));
}
}
}

View File

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

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RigidbodySpeedLimiter : MonoBehaviour
{
public float maxSpeed = 5f;
public float minSpeed = 2f;
private Rigidbody _rigidbody;
private void Start()
{
_rigidbody = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
if (_rigidbody.IsSleeping()) return;
float velocity = _rigidbody.velocity.magnitude;
Debug.Log(velocity);
if (velocity < minSpeed)
{
_rigidbody.velocity = _rigidbody.velocity.normalized * minSpeed;
}
else if (velocity > maxSpeed)
{
_rigidbody.velocity = Vector3.ClampMagnitude(_rigidbody.velocity, maxSpeed);
}
}
}

View File

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

View File

@@ -0,0 +1,26 @@
using UnityEngine.XR.Interaction.Toolkit;
public class XRGrabVelocityTracked : XRGrabInteractable
{
protected override void OnSelectEntered(XRBaseInteractor interactor)
{
SetParentToXRRig();
base.OnSelectEntered(interactor);
}
protected override void OnSelectExited(XRBaseInteractor interactor)
{
SetParentToWorld();
base.OnSelectExited(interactor);
}
public void SetParentToXRRig()
{
transform.SetParent(selectingInteractor.transform);
}
public void SetParentToWorld()
{
transform.SetParent(null);
}
}

View File

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