Updated Player and MainGame scene, fix bugs #281

Merged
glencelow merged 7 commits from PlayerController into main 2022-11-25 16:34:51 +08:00
4 changed files with 39 additions and 13 deletions
Showing only changes of commit 9473359076 - Show all commits

View File

@ -8372,7 +8372,7 @@
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: 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} Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1} Scale: {x: 1, y: 1, z: 1}
IsActive: true IsActive: true
@ -8394,7 +8394,7 @@
Colliders: Colliders:
- Is Trigger: true - Is Trigger: true
Type: Box Type: Box
Half Extents: {x: 1.79999995, y: 1, z: 0.200000003} Half Extents: {x: 1.79999995, y: 1, z: 1}
Friction: 0.400000006 Friction: 0.400000006
Bounciness: 0 Bounciness: 0
Density: 1 Density: 1
@ -8561,6 +8561,7 @@
throwForce: [50, 50, 50] throwForce: [50, 50, 50]
delayTimer: 1 delayTimer: 1
aimingLength: 0.5 aimingLength: 0.5
rayDistance: 1
- EID: 3 - EID: 3
Name: HoldingPoint Name: HoldingPoint
IsActive: true IsActive: true

View File

@ -81,7 +81,6 @@ public partial class LeafPatrol : BehaviourTreeNode
} }
Vector3 remainingDistance = Vector3.Zero; Vector3 remainingDistance = Vector3.Zero;
Debug.Log($"{waypoints.Count}");
if (currentWaypointIndex > 0) if (currentWaypointIndex > 0)
{ {

View File

@ -24,24 +24,33 @@ public class PickAndThrow : Script
private float lastZDir; private float lastZDir;
private bool inRange = false; private bool inRange = false;
private Collider collider;
private BoxCollider cs;
[Tooltip("Lenght of ray")]
public float rayDistance = 3;
protected override void awake() protected override void awake()
{ {
playerTran = GetComponent<Transform>();
if (!playerTran)
Debug.Log("PLAYERTRANSFORM EMPTY"); ;
pc = GetScript<PlayerController>(); pc = GetScript<PlayerController>();
if(!pc) if(!pc)
Debug.Log("PLAYER CONTROLLER EMPTY"); Debug.LogError("PLAYER CONTROLLER EMPTY");
raccoonHoldLocation = GetComponentInChildren<Transform>(); raccoonHoldLocation = GetComponentInChildren<Transform>();
if (!raccoonHoldLocation) if (!raccoonHoldLocation)
Debug.Log("CHILD EMPTY"); Debug.LogError("CHILD EMPTY");
tpc = GetScriptInChildren<ThirdPersonCamera>(); tpc = GetScriptInChildren<ThirdPersonCamera>();
if(!tpc) if(!tpc)
Debug.Log("TPC EMPTY"); Debug.LogError("TPC EMPTY");
collider = GetComponent<Collider>();
if (!collider)
Debug.LogError("COLLIDER EMPTY");
else
{
cs = collider.GetCollisionShape<BoxCollider>(0);
}
timer = delayTimer; timer = delayTimer;
} }
@ -119,6 +128,11 @@ public class PickAndThrow : Script
} }
} }
protected override void fixedUpdate()
{
CastRay();
}
private void ResetItemObject() private void ResetItemObject()
{ {
itemRidibody = null; itemRidibody = null;
@ -171,10 +185,22 @@ 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) protected override void onCollisionEnter(CollisionInfo info)
{ {

View File

@ -27,7 +27,7 @@ public class PlayerController : Script
}*/ }*/
public RigidBody rb { get; set; } public RigidBody rb { get; set; }
private Transform tranform; public Transform tranform { get; set; }
private Camera cam; private Camera cam;
public CameraArm camArm { get; set; } public CameraArm camArm { get; set; }
private PickAndThrow pat; private PickAndThrow pat;