Browse Source

oar mechanichs

main
Joshua Reason 1 year ago
parent
commit
c563d51770
3 changed files with 14 additions and 15 deletions
  1. +7
    -8
      Assets/Scripts/Player/BoatRowController.cs
  2. +1
    -1
      Assets/Scripts/Player/HandController.cs
  3. +6
    -6
      Assets/Scripts/Player/OarController.cs

+ 7
- 8
Assets/Scripts/Player/BoatRowController.cs View File

@ -60,7 +60,7 @@ public class BoatRowController : MonoBehaviour
OarController oar = other.GetComponentInParent<OarController>();
if (oar != null)
{
m_lastKnownOarPosition = m_oarTip.position;
m_lastKnownOarPosition = m_oarTip.localPosition;
}
}
@ -69,25 +69,24 @@ public class BoatRowController : MonoBehaviour
OarController oar = other.GetComponentInParent<OarController>();
if(oar != null)
{
Vector3 direction = m_lastKnownOarPosition - m_oarTip.position;
direction = Vector3.Project(direction,transform.forward);
Vector3 direction = m_lastKnownOarPosition - m_oarTip.localPosition;
float directionality = Vector3.Dot(direction,transform.forward);
float directionality = Vector3.Dot(direction,Vector3.forward);
if (directionality > 0)
{
// Debug.Log($"Row! ({directionality})");
Debug.Log($"Row! ({directionality})");
m_OnRow.Invoke();
}
else
{
// Debug.Log($"No Row: {directionality}");
Debug.Log($"No Row: {directionality}");
}
m_lastKnownOarPosition=m_oarTip.position;
m_lastKnownOarPosition=m_oarTip.localPosition;
}
else
{
// Debug.Log($"Not Oar: {other.gameObject}");
Debug.Log($"Not Oar: {other.gameObject}");
}
}

+ 1
- 1
Assets/Scripts/Player/HandController.cs View File

@ -116,7 +116,7 @@ public class HandController : MonoBehaviour
Quaternion rotation = Quaternion.LookRotation(m_axisForward.normalized, m_axisNormal.normalized);
Vector3 axisInput = transform.rotation * rotation * new Vector3(input.x, 0, input.y);
Vector3 axisInput = rotation * new Vector3(input.x, 0, input.y);
Vector3 desiredPosition = m_startPosition + axisInput * m_armRange;
transform.localPosition = Vector3.Lerp(transform.localPosition, desiredPosition, m_armSpeed);

+ 6
- 6
Assets/Scripts/Player/OarController.cs View File

@ -96,11 +96,11 @@ public class OarController : MonoBehaviour
Quaternion rotation = Quaternion.LookRotation(forward, direction);
//transform.rotation = rotation;
//transform.position = m_rightHand.transform.position - direction * m_distanceFromRightHand;
transform.rotation = rotation;
transform.position = m_rightHand.transform.position - direction * m_distanceFromRightHand;
//MoveOarToPosition(m_rightHand.transform.position - direction * m_distanceFromRightHand);
m_oarRigidbody.MoveRotation(rotation);
m_oarRigidbody.MovePosition(m_rightHand.transform.position - direction * m_distanceFromRightHand);
//m_oarRigidbody.MoveRotation(rotation);
//m_oarRigidbody.MovePosition(m_rightHand.transform.position - direction * m_distanceFromRightHand);
//MoveOarToRotation(rotation);
@ -128,12 +128,12 @@ public class OarController : MonoBehaviour
Collider[] col = Physics.OverlapBox(transform.position + m_boxCollider.center, m_boxCollider.size / 2, rotation);
if (col.Intersect(m_forbiddenColliders).Any())
{
Debug.Log($"Forbidden collision: {string.Join(", ", col.Intersect(m_forbiddenColliders))}");
//Debug.Log($"Forbidden collision: {string.Join(", ", col.Intersect(m_forbiddenColliders))}");
return true;
}
else
{
Debug.Log($"Ignored collision: {string.Join(", ", col.Except(m_forbiddenColliders))}");
// Debug.Log($"Ignored collision: {string.Join(", ", col.Except(m_forbiddenColliders))}");
}
return false;

Loading…
Cancel
Save