diff --git a/Assets/Scenes/MainGame.shade b/Assets/Scenes/MainGame.shade index 600c6161..16de4ea8 100644 --- a/Assets/Scenes/MainGame.shade +++ b/Assets/Scenes/MainGame.shade @@ -8372,7 +8372,7 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 2.24178481, y: 1.4327563, z: 8.89205742} + Translate: {x: 2.24178481, y: 1.4327563, z: 9.3920002} Rotate: {x: -0, y: 0, z: -0} Scale: {x: 1, y: 1, z: 1} IsActive: true @@ -8394,7 +8394,7 @@ Colliders: - Is Trigger: true Type: Box - Half Extents: {x: 1.79999995, y: 1, z: 0.200000003} + Half Extents: {x: 1.79999995, y: 1, z: 1} Friction: 0.400000006 Bounciness: 0 Density: 1 @@ -8561,6 +8561,7 @@ throwForce: [50, 50, 50] delayTimer: 1 aimingLength: 0.5 + rayDistance: 1 - EID: 3 Name: HoldingPoint IsActive: true diff --git a/Assets/Scripts/AIBehaviour/Implemented/LeafNodes/LeafPatrol.cs b/Assets/Scripts/AIBehaviour/Implemented/LeafNodes/LeafPatrol.cs index 1e68a7f2..bce56e59 100644 --- a/Assets/Scripts/AIBehaviour/Implemented/LeafNodes/LeafPatrol.cs +++ b/Assets/Scripts/AIBehaviour/Implemented/LeafNodes/LeafPatrol.cs @@ -81,7 +81,6 @@ public partial class LeafPatrol : BehaviourTreeNode } Vector3 remainingDistance = Vector3.Zero; - Debug.Log($"{waypoints.Count}"); if (currentWaypointIndex > 0) { diff --git a/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs index b9737685..27243029 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs @@ -24,24 +24,33 @@ public class PickAndThrow : Script private float lastZDir; private bool inRange = false; + private Collider collider; + private BoxCollider cs; + + [Tooltip("Lenght of ray")] + public float rayDistance = 3; protected override void awake() { - playerTran = GetComponent(); - if (!playerTran) - Debug.Log("PLAYERTRANSFORM EMPTY"); ; - pc = GetScript(); if(!pc) - Debug.Log("PLAYER CONTROLLER EMPTY"); + Debug.LogError("PLAYER CONTROLLER EMPTY"); raccoonHoldLocation = GetComponentInChildren(); if (!raccoonHoldLocation) - Debug.Log("CHILD EMPTY"); + Debug.LogError("CHILD EMPTY"); tpc = GetScriptInChildren(); if(!tpc) - Debug.Log("TPC EMPTY"); + Debug.LogError("TPC EMPTY"); + + collider = GetComponent(); + if (!collider) + Debug.LogError("COLLIDER EMPTY"); + else + { + cs = collider.GetCollisionShape(0); + } timer = delayTimer; } @@ -119,6 +128,11 @@ public class PickAndThrow : Script } } + protected override void fixedUpdate() + { + CastRay(); + } + private void ResetItemObject() { itemRidibody = null; @@ -171,11 +185,23 @@ public class PickAndThrow : Script } } - private void DelayCheck() + private void CastRay() { - timer += Time.DeltaTimeF; + if (pc != null && cs != null) + { + Vector3 dirNor = pc.tranform.Forward; + //change when cs.HalfExtents.z works + //cs.HalfExtents.z + Vector3 playerRayPos = pc.tranform.GlobalPosition + (dirNor * (0.3f + 0.1f)); + playerRayPos.y += 0.1f; + dirNor.Normalise(); + RaycastHit ray1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance); + RaycastHit ray2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance); + RaycastHit ray3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.5f); + } } + protected override void onCollisionEnter(CollisionInfo info) { } diff --git a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs index b8a096e9..e1ad2512 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs @@ -27,7 +27,7 @@ public class PlayerController : Script }*/ public RigidBody rb { get; set; } - private Transform tranform; + public Transform tranform { get; set; } private Camera cam; public CameraArm camArm { get; set; } private PickAndThrow pat;