Merge branch 'staging' of https://cgvrgit.ulno.net/helar/Heroes_of_Hiis into joonasp_Milestone2

This commit is contained in:
joonasp
2022-04-08 21:14:07 +03:00
1164 changed files with 180915 additions and 983 deletions

View File

@@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class CuttableTree : MonoBehaviour
{
private Quaternion rotation;
public GameObject stumpPrefab;
public GameObject logPrefab;
[SerializeField]
private UnityEvent onCut;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Cutter")
{
rotation = transform.rotation;
rotation *= Quaternion.AngleAxis(20, Vector3.up);
Instantiate(stumpPrefab, transform.position, rotation);
Instantiate(logPrefab, transform.position+new Vector3(0, 1, 0), rotation);
onCut.Invoke();
Destroy(gameObject);
}
}
}

View File

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

View File

@@ -9,7 +9,7 @@ public class ItemSpawner : MonoBehaviour
public GameObject placeToSpawn;
public void SpawnItem()
{
//Debug.Log("Spawned " + objectToSpawn);
Debug.Log("Spawned " + objectToSpawn);
Instantiate(objectToSpawn, placeToSpawn.transform);
}
}

View File

@@ -104,7 +104,7 @@ public class ActionGestureInteraction : MonoBehaviour
void InstantiateIceBolt(GameObject item)
{
var projectileObj = Instantiate(item, rightHandTransform.position, Quaternion.identity) as GameObject;
var projectileObj = Instantiate(item, rightHandTransform.position, playerCamera.transform.rotation) as GameObject;
projectileObj.GetComponent<Rigidbody>().velocity = (destination - rightHandTransform.position).normalized * projectileSpeed;
}
}

View File

@@ -26,22 +26,27 @@ public class PortalTeleporter : MonoBehaviour
traveller = other.gameObject.transform;
if (_portalIsEnabled && !_justUsed)
{
linkedPortal._portalIsEnabled = false;
_travellerIsOverlapping = true;
if (other.tag == "Throwable")
if (other.name.StartsWith("Holster"))
{
Debug.Log("Portal entered by throwable");
HandleThrowable();
Debug.Log("holster");
}
else if (other.tag == "Player")
else
{
Debug.Log("Portal entered by player");
HandlePlayer();
linkedPortal._portalIsEnabled = false;
_travellerIsOverlapping = true;
if (other.tag == "Throwable")
{
Debug.Log("Portal entered by throwable");
HandleThrowable();
}
else if (other.tag == "Player")
{
Debug.Log("Portal entered by player");
HandlePlayer();
}
}
}
}
private void HandlePlayer()
{
Vector3 portalToTraveller = traveller.position - transform.position;
@@ -54,7 +59,10 @@ public class PortalTeleporter : MonoBehaviour
rotationDiff += 180;
traveller.Rotate(Vector3.up, rotationDiff);
Vector3 positionOffset = Quaternion.Euler(0f, rotationDiff, 0f) * portalToTraveller;
// Teleport
traveller.position = linkedPortalTransform.position + positionOffset;
AudioSource.PlayClipAtPoint(TeleportSound, traveller.position, 1);
_travellerIsOverlapping = false;
_portalIsEnabled = false;

View File

@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Projectile : MonoBehaviour
{
private bool collided;
Vector3 oldEulerAngles;
private void Start()
{
// Will always be destroyed after 10 seconds.
Destroy(gameObject, 10);
oldEulerAngles = transform.rotation.eulerAngles;
}
private void Update()
{
if (oldEulerAngles != transform.rotation.eulerAngles)
{
Destroy(gameObject);
}
}
private void onCollisionEnter(Collider other)
{
if (other.gameObject.tag != "IceBolt" && other.gameObject.tag != "Player" && !collided)
{
collided = true;
Destroy(gameObject);
}
}
private void onTriggerEnter(Collider other)
{
if (other.gameObject.tag != "IceBolt" && other.gameObject.tag != "Player" && !collided)
{
collided = true;
Destroy(gameObject);
}
}
}

View File

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

View File

@@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VRFootIK : MonoBehaviour
{
private Animator animator;
public Vector3 footOffset;
[Range(0,1)]
public float rightFootPosWeight = 1;
[Range(0, 1)]
public float rightFootRotWeight = 1;
[Range(0,1)]
public float leftFootPosWeight = 1;
[Range(0, 1)]
public float leftFootRotWeight = 1;
// Start is called before the first frame update
void Start()
{
animator = GetComponent<Animator>();
}
private void OnAnimatorIK(int layerIndex)
{
Vector3 rightFootPos = animator.GetIKPosition(AvatarIKGoal.RightFoot);
RaycastHit hit;
bool hasHit = Physics.Raycast(rightFootPos + Vector3.up, Vector3.down, out hit);
if (hasHit)
{
animator.SetIKPositionWeight(AvatarIKGoal.RightFoot, rightFootPosWeight);
animator.SetIKPosition(AvatarIKGoal.RightFoot, hit.point + footOffset);
Quaternion rightFootRotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(transform.forward, hit.normal), hit.normal);
animator.SetIKRotationWeight(AvatarIKGoal.RightFoot, rightFootRotWeight);
animator.SetIKRotation(AvatarIKGoal.RightFoot, rightFootRotation);
}
else
{
animator.SetIKPositionWeight(AvatarIKGoal.RightFoot, 0);
}
Vector3 leftFootPos = animator.GetIKPosition(AvatarIKGoal.LeftFoot);
hasHit = Physics.Raycast(leftFootPos + Vector3.up, Vector3.down, out hit);
if (hasHit)
{
animator.SetIKPositionWeight(AvatarIKGoal.LeftFoot, leftFootPosWeight);
animator.SetIKPosition(AvatarIKGoal.LeftFoot, hit.point + footOffset);
Quaternion leftFootRotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(transform.forward, hit.normal), hit.normal);
animator.SetIKRotationWeight(AvatarIKGoal.LeftFoot, leftFootRotWeight);
animator.SetIKRotation(AvatarIKGoal.LeftFoot, leftFootRotation);
}
else
{
animator.SetIKPositionWeight(AvatarIKGoal.LeftFoot, 0);
}
}
}

View File

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

View File

@@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class VRMap
{
public Transform vrTarget;
public Transform rigTarget;
public Vector3 trackingOffsetPosition;
public Vector3 trackingOffsetRotation;
public void Map()
{
rigTarget.position = vrTarget.TransformPoint(trackingOffsetPosition);
rigTarget.rotation = vrTarget.rotation * Quaternion.Euler(trackingOffsetRotation);
}
}
public class VRRig : MonoBehaviour
{
public VRMap head;
public VRMap leftHand;
public VRMap rightHand;
public int turnSmoothness;
public Transform headConstraint;
public Vector3 headBodyOffset;
// Start is called before the first frame update
void Start()
{
headBodyOffset = transform.position - headConstraint.position;
}
// Update is called once per frame
void FixedUpdate()
{
transform.position = headConstraint.position + headBodyOffset;
transform.forward = Vector3.Lerp(transform.forward, Vector3.ProjectOnPlane(headConstraint.up, Vector3.up).normalized, Time.deltaTime * turnSmoothness);
head.Map();
leftHand.Map();
rightHand.Map();
}
}

View File

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

View File

@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class spellcaster : MonoBehaviour
{
public GameObject projectile;
public float projectileSpeed;
void Update()
{
if (true)
{
GameObject icebolt = Instantiate(projectile, transform) as GameObject;
Rigidbody rb = icebolt.GetComponent<Rigidbody>();
rb.velocity = transform.forward * projectileSpeed;
}
}
}

View File

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