camera offset rotation fix along with ai not hard hard for box collider

This commit is contained in:
Glence 2023-03-09 18:47:06 +08:00
parent ec91bdb687
commit 2eee1d4ab7
4 changed files with 26 additions and 13 deletions

View File

@ -2419,7 +2419,7 @@
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: 0, z: 0} Translate: {x: 0, y: 0, z: 0}
Rotate: {x: 0, y: 0, z: 0} Rotate: {x: -1.48352981, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1} Scale: {x: 1, y: 1, z: 1}
IsActive: true IsActive: true
Renderable Component: Renderable Component:
@ -4107,7 +4107,7 @@
Collider Component: Collider Component:
Colliders: Colliders:
- Is Trigger: false - Is Trigger: false
Collision Tag: 0 Collision Tag: 1
Type: Box Type: Box
Half Extents: {x: 20, y: 0.100000001, z: 20} Half Extents: {x: 20, y: 0.100000001, z: 20}
Friction: 0.400000006 Friction: 0.400000006
@ -4299,6 +4299,8 @@
Enabled: true Enabled: true
Score: 50 Score: 50
currCategory: 1 currCategory: 1
returnBack: false
firstPostion: [0, 0, 0]
density: 1 density: 1
dontReturn: false dontReturn: false
soundDistance: 10 soundDistance: 10
@ -4311,7 +4313,7 @@
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: Transform Component:
Translate: {x: 3.22328258, y: 1.02709854, z: -0.57395637} Translate: {x: 3.22328258, y: 1.11577427, z: -0.57395637}
Rotate: {x: 5.62993963e-09, y: -7.03049191e-17, z: -1.92319405e-08} Rotate: {x: 5.62993963e-09, y: -7.03049191e-17, z: -1.92319405e-08}
Scale: {x: 1, y: 1, z: 1} Scale: {x: 1, y: 1, z: 1}
IsActive: true IsActive: true
@ -4351,6 +4353,8 @@
Enabled: true Enabled: true
Score: 500 Score: 500
currCategory: 2 currCategory: 2
returnBack: false
firstPostion: [0, 0, 0]
density: 1 density: 1
dontReturn: false dontReturn: false
soundDistance: 10 soundDistance: 10
@ -4403,6 +4407,8 @@
Enabled: true Enabled: true
Score: 10 Score: 10
currCategory: 0 currCategory: 0
returnBack: false
firstPostion: [0, 0, 0]
density: 1 density: 1
dontReturn: false dontReturn: false
soundDistance: 10 soundDistance: 10
@ -4455,6 +4461,8 @@
Enabled: true Enabled: true
Score: 10 Score: 10
currCategory: 0 currCategory: 0
returnBack: false
firstPostion: [0, 0, 0]
density: 1 density: 1
dontReturn: false dontReturn: false
soundDistance: 10 soundDistance: 10
@ -4804,7 +4812,7 @@
IsActive: true IsActive: true
Animator Component: Animator Component:
Rig: 72178939 Rig: 72178939
Clip: 72178939 AnimationController: 0
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 219 - EID: 219
@ -4823,7 +4831,7 @@
IsActive: true IsActive: true
Animator Component: Animator Component:
Rig: 80728853 Rig: 80728853
Clip: 80728853 AnimationController: 0
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 218 - EID: 218
@ -4842,7 +4850,7 @@
IsActive: true IsActive: true
Animator Component: Animator Component:
Rig: 80500944 Rig: 80500944
Clip: 80500944 AnimationController: 0
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 220 - EID: 220
@ -4861,7 +4869,7 @@
IsActive: true IsActive: true
Animator Component: Animator Component:
Rig: 76715962 Rig: 76715962
Clip: 76715962 AnimationController: 0
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 198 - EID: 198

View File

@ -156,7 +156,7 @@ public partial class LeafSearch : BehaviourTreeNode
//Draw a ray, succeed if ray is unobstructed //Draw a ray, succeed if ray is unobstructed
Vector3 eyePosition = transform.GlobalPosition + eyeOffset; Vector3 eyePosition = transform.GlobalPosition + eyeOffset;
BoxCollider playerCollider = player.GetValueOrDefault().GetComponent<Collider>().GetCollisionShape<BoxCollider>(0); Collider playerCollider = player.GetValueOrDefault().GetComponent<Collider>();
if (playerCollider == null) if (playerCollider == null)
{ {
//Debug.Log("Failure: Player has no collider"); //Debug.Log("Failure: Player has no collider");
@ -167,7 +167,7 @@ public partial class LeafSearch : BehaviourTreeNode
} }
//Ray destination to target the centre of the player's collider instead of transform position //Ray destination to target the centre of the player's collider instead of transform position
//Since transform position is often the raccoon's base and the ray needs to hit somewhere higher to be more reliable //Since transform position is often the raccoon's base and the ray needs to hit somewhere higher to be more reliable
Vector3 rayDestination = plrT.GlobalPosition + plrT.GlobalScale * playerCollider.PositionOffset; Vector3 rayDestination = plrT.GlobalPosition + plrT.GlobalScale * playerCollider.GetCollisionShape(0).PositionOffset;
Ray sightRay = new Ray(eyePosition, rayDestination - eyePosition); Ray sightRay = new Ray(eyePosition, rayDestination - eyePosition);
RaycastHit sightRayHit = Physics.Raycast(sightRay, false, (ushort)65535)[0]; RaycastHit sightRayHit = Physics.Raycast(sightRay, false, (ushort)65535)[0];
//As of November 2022, RaycastHit contains only the FIRST object hit by //As of November 2022, RaycastHit contains only the FIRST object hit by

View File

@ -86,12 +86,17 @@ public class Item : Script
if (returnBack && !dontReturn) if (returnBack && !dontReturn)
{ {
if (rb)
{
rb.LinearVelocity = Vector3.Zero;
rb.AngularVelocity = Vector3.Zero;
rb.ClearForces();
rb.ClearTorque();
}
if(transform) if(transform)
transform.LocalPosition = firstPostion; transform.LocalPosition = firstPostion;
if (rb)
rb.LinearVelocity = Vector3.Zero;
returnBack = false; returnBack = false;
} }

View File

@ -280,7 +280,7 @@ namespace SHADE
if (arm->lookAtCameraOrigin) if (arm->lookAtCameraOrigin)
CameraLookAt(camera, camera.position + arm->GetTargetOffset()); CameraLookAt(camera, camera.position + tOffset);
} }