Skip to content
Snippets Groups Projects
Commit f034f7e5 authored by Joey Docter's avatar Joey Docter :eye:
Browse files

changed collision with raycast for the movable displacement

parent 6fd24438
Branches
1 merge request!1Develop
This diff is collapsed.
This diff is collapsed.
......@@ -149,4 +149,4 @@ Rigidbody:
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
m_CollisionDetection: 1
......@@ -10,7 +10,6 @@ namespace VR.Data
internal bool isHitByLaser = false;
[SerializeField] private LayerMask wallMask;
[SerializeField] private SphereCollider sphereCollider;
private readonly List<Vector3> rotationList = new();
......@@ -18,21 +17,6 @@ namespace VR.Data
private Vector3 originalPosition;
private Vector3 rotationValue;
private bool hitTarget;
private void OnTriggerEnter(Collider _other)
{
if ((wallMask.value & (1 << _other.transform.gameObject.layer)) > 0)
{
if (!rotationList.Contains(rotationValue))
{
rotationList.Add(rotationValue);
}
hitTarget = true;
}
}
internal void Initialize(MovableObject _data, Vector3 _startPosition)
{
objectData = _data;
......@@ -48,13 +32,16 @@ namespace VR.Data
{
rotationValue = GetRotationID(_rotation, _mouseValue);
if (rotationList.Contains(rotationValue) && hitTarget)
if (rotationList.Contains(rotationValue))
{
if (rotationList.Contains(-rotationValue))
{
rotationList.Remove(-rotationValue);
}
return false;
}
hitTarget = false;
return true;
}
......@@ -63,6 +50,31 @@ namespace VR.Data
Vector3 diplacementValues = objectData.vectorDictionary[VectorTypes.DISPLACEMENT];
transform.position = originalPosition + (diplacementValues.z * transform.forward) + (diplacementValues.x * transform.right) + (diplacementValues.y * transform.up);
HitValue();
}
private void HitValue()
{
Ray ray = new(transform.position, rotationValue);
if (Physics.Raycast(ray, out RaycastHit hit, 1.0f))
{
if ((wallMask.value & (1 << hit.transform.gameObject.layer)) <= 0)
{
return;
}
if (!rotationList.Contains(rotationValue))
{
rotationList.Add(rotationValue);
}
}
if (rotationList.Contains(-rotationValue))
{
rotationList.Remove(-rotationValue);
}
}
private Vector3 GetRotationID(Vector3 _rotation, int _mouseValue)
......
......@@ -40,7 +40,7 @@ namespace VR.Data
{
if (isInPortal && playerController.holdingObject != null)
{
GetOperatorOnRotation();
UpdateValues(GetOperatorOnRotation());
}
}
......@@ -107,7 +107,7 @@ namespace VR.Data
}
}
private void GetOperatorOnRotation()
private Vector3 GetOperatorOnRotation()
{
Vector3 newForward = Camera.main.transform.forward;
......@@ -120,6 +120,11 @@ namespace VR.Data
Vector3 rotation = playerController.holdingObject.physicsManager.PlayerLocalRotationToWorldAxis(newForward);
playerController.holdingObject.physicsManager.SetRotationInfo(ref directionText, rotation);
return rotation;
}
private void UpdateValues(Vector3 rotation)
{
float mouseScroll = playerController.holdingObject.playerControls.Vector.AddValue.ReadValue<Vector2>().y;
if (mouseScroll >= 1.0f && (endTarget == null || endTarget.CanMoveOnAxis(rotation, 1)))
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment