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
6 changed files with 105 additions and 84 deletions
Showing only changes of commit 181af5b3e5 - Show all commits

View File

@ -1,4 +1,4 @@
Start in Fullscreen: false
Starting Scene ID: 86098106
Starting Scene ID: 97158628
Window Size: {x: 1920, y: 1080}
Window Title: SHADE Engine

View File

@ -8236,7 +8236,7 @@
Colliders:
- Is Trigger: false
Type: Box
Half Extents: {x: 0.100000001, y: 0.100000001, z: 0.100000001}
Half Extents: {x: 0.200000003, y: 0.200000003, z: 0.200000003}
Friction: 0.400000006
Bounciness: 0
Density: 1
@ -8280,7 +8280,7 @@
Colliders:
- Is Trigger: false
Type: Box
Half Extents: {x: 0.25, y: 0.075000003, z: 0.25}
Half Extents: {x: 0.5, y: 0.150000006, z: 0.5}
Friction: 0.400000006
Bounciness: 0
Density: 1
@ -8324,7 +8324,7 @@
Colliders:
- Is Trigger: false
Type: Box
Half Extents: {x: 0.150000006, y: 0.150000006, z: 0.150000006}
Half Extents: {x: 0.300000012, y: 0.300000012, z: 0.300000012}
Friction: 0.400000006
Bounciness: 0
Density: 1
@ -8538,6 +8538,7 @@
cameraArmOffSet: [0, 0.25, 0]
delayTimer: 1
aimingLength: 0.5
throwItem: false
rayDistance: 0.5
- EID: 3
Name: HoldingPoint
@ -8586,6 +8587,8 @@
turnSpeedPitch: 0.300000012
turnSpeedYaw: 0.5
pitchClamp: 45
inverseXControls: true
inverseYControls: true
- EID: 9
Name: PlayerBag
IsActive: true
@ -8668,8 +8671,8 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 3.57627869e-07, y: 0, z: -0.0171995163}
Rotate: {x: -1.31316483e-07, y: 3.60887498e-09, z: 5.27542454e-11}
Translate: {x: -0.0586929321, y: 0, z: 0}
Rotate: {x: -0, y: 3.6088712e-09, z: 1.97286229e-16}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Renderable Component:
@ -8708,9 +8711,9 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 2.38418579e-07, y: 0, z: 0.0325665474}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
Translate: {x: -0.0104182959, y: 0, z: -0.0662035942}
Rotate: {x: -0, y: 0.174533099, z: -0}
Scale: {x: 0.999999881, y: 1, z: 0.999999881}
IsActive: true
Renderable Component:
Mesh: 145439064
@ -8748,9 +8751,9 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.0502780676, y: 1.18017197e-05, z: 6.96182251e-05}
Rotate: {x: 0.021297913, y: 0.00146768149, z: -5.48749846e-08}
Scale: {x: 1, y: 1, z: 1}
Translate: {x: 0.0431699753, y: 1.18017197e-05, z: -0.0288243294}
Rotate: {x: -0, y: 0, z: 0.174533099}
Scale: {x: 0.999999881, y: 0.999999583, z: 1}
IsActive: true
Renderable Component:
Mesh: 139411134
@ -8788,8 +8791,8 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0.0364142656, y: 7.39097595e-06, z: 6.6280365e-05}
Rotate: {x: 0, y: 0, z: 0}
Translate: {x: 0.0341523886, y: 0.0088942796, z: 0.0554270744}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Renderable Component:
@ -8822,13 +8825,13 @@
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 176
- EID: 65707
Name: Plate
IsActive: true
NumberOfChildren: 4
Components:
Transform Component:
Translate: {x: 3.23750496, y: 0.1594823, z: 6.75670671}
Translate: {x: 2.97949171, y: 0.1594823, z: 7.20125246}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 0.999979734, y: 1, z: 0.999979734}
IsActive: true
@ -8866,14 +8869,14 @@
Enabled: true
threshHold: 0.100000001
force: 1
- EID: 175
- EID: 65703
Name: Piece1
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 3.57627869e-07, y: 0, z: -0.0171995163}
Rotate: {x: -1.31316483e-07, y: 3.60887498e-09, z: 5.27542454e-11}
Translate: {x: -0.0586929321, y: 0, z: 0}
Rotate: {x: -0, y: 3.6088712e-09, z: 1.97286229e-16}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Renderable Component:
@ -8906,15 +8909,15 @@
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 174
- EID: 65704
Name: Piece2
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 2.38418579e-07, y: 0, z: 0.0325665474}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
Translate: {x: -0.0104182959, y: 0, z: -0.0662035942}
Rotate: {x: -0, y: 0.174533099, z: -0}
Scale: {x: 0.999999881, y: 1, z: 0.999999881}
IsActive: true
Renderable Component:
Mesh: 145439064
@ -8946,15 +8949,15 @@
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 173
- EID: 65705
Name: Piece3
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.0502780676, y: 1.18017197e-05, z: 6.96182251e-05}
Rotate: {x: 0.021297913, y: 0.00146768149, z: -5.48749846e-08}
Scale: {x: 1, y: 1, z: 1}
Translate: {x: 0.0431699753, y: 1.18017197e-05, z: -0.0288243294}
Rotate: {x: -0, y: 0, z: 0.174533099}
Scale: {x: 0.999999881, y: 0.999999583, z: 1}
IsActive: true
Renderable Component:
Mesh: 139411134
@ -8986,14 +8989,14 @@
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 172
- EID: 65706
Name: Piece4
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0.0364142656, y: 7.39097595e-06, z: 6.6280365e-05}
Rotate: {x: 0, y: 0, z: 0}
Translate: {x: 0.0341523886, y: 0.0088942796, z: 0.0554270744}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Renderable Component:
@ -9026,13 +9029,13 @@
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 171
- EID: 65712
Name: Plate
IsActive: true
NumberOfChildren: 4
Components:
Transform Component:
Translate: {x: 3.48429918, y: 0.1594823, z: 7.54602051}
Translate: {x: 3.0075531, y: 0.1594823, z: 8.19898987}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 0.999979734, y: 1, z: 0.999979734}
IsActive: true
@ -9070,14 +9073,14 @@
Enabled: true
threshHold: 0.100000001
force: 1
- EID: 170
- EID: 65708
Name: Piece1
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 3.57627869e-07, y: 0, z: -0.0171995163}
Rotate: {x: -1.31316483e-07, y: 3.60887498e-09, z: 5.27542454e-11}
Translate: {x: -0.0586929321, y: 0, z: 0}
Rotate: {x: -0, y: 3.6088712e-09, z: 1.97286229e-16}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Renderable Component:
@ -9110,15 +9113,15 @@
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 169
- EID: 65709
Name: Piece2
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 2.38418579e-07, y: 0, z: 0.0325665474}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
Translate: {x: -0.0104182959, y: 0, z: -0.0662035942}
Rotate: {x: -0, y: 0.174533099, z: -0}
Scale: {x: 0.999999881, y: 1, z: 0.999999881}
IsActive: true
Renderable Component:
Mesh: 145439064
@ -9150,15 +9153,15 @@
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 168
- EID: 65710
Name: Piece3
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.0502780676, y: 1.18017197e-05, z: 6.96182251e-05}
Rotate: {x: 0.021297913, y: 0.00146768149, z: -5.48749846e-08}
Scale: {x: 1, y: 1, z: 1}
Translate: {x: 0.0431699753, y: 1.18017197e-05, z: -0.0288243294}
Rotate: {x: -0, y: 0, z: 0.174533099}
Scale: {x: 0.999999881, y: 0.999999583, z: 1}
IsActive: true
Renderable Component:
Mesh: 139411134
@ -9190,14 +9193,14 @@
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 167
- EID: 65711
Name: Piece4
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0.0364142656, y: 7.39097595e-06, z: 6.6280365e-05}
Rotate: {x: 0, y: 0, z: 0}
Translate: {x: 0.0341523886, y: 0.0088942796, z: 0.0554270744}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Renderable Component:

View File

@ -15,7 +15,7 @@ public class PickAndThrow : Script
private float timer;
private PlayerController pc;
private Transform itemTransform;
private RigidBody itemRidibody;
private RigidBody itemRidigBody;
private Collider itemCollider;
private Item itemScript;
private Transform raccoonHoldLocation;
@ -23,6 +23,7 @@ public class PickAndThrow : Script
private float lastXDir;
private float lastZDir;
private bool inRange = false;
public bool throwItem = false;
[Tooltip("Lenght of ray")]
public float rayDistance = 1;
@ -45,18 +46,21 @@ public class PickAndThrow : Script
}
protected override void update()
{
if(timer <= delayTimer)
timer += Time.DeltaTimeF;
CalculateDir();
CastRay();
if (pc && itemRidibody && itemTransform && itemCollider)
if (pc && itemRidigBody && itemTransform && itemCollider)
{
if (pc.holdItem)
{
itemTransform.LocalPosition = raccoonHoldLocation.GlobalPosition;
itemTransform.LocalRotation = pc.tranform.LocalRotation;
itemRidigBody.LinearVelocity = Vector3.Zero;
itemRidigBody.AngularVelocity = Vector3.Zero;
if (Input.GetMouseButtonDown(Input.MouseCode.LeftButton))
{
@ -68,27 +72,15 @@ public class PickAndThrow : Script
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming)
{
Audio.PlaySFXOnce2D("event:/Raccoon/raccoon_throw");
itemRidigBody.IsGravityEnabled = true;
itemCollider.GetCollisionShape(0).IsTrigger = false;
pc.isAiming = false;
pc.camArm.TargetOffset = Vector3.Zero;
if (tpc)
pc.camArm.ArmLength = tpc.armLength;
pc.holdItem = false;
inRange = false;
itemRidibody.IsGravityEnabled = true;
itemCollider.Enabled = true;
if (itemScript)
{
Vector3 vec = new Vector3(throwForce.x * lastXDir, throwForce.y, throwForce.z * lastZDir);
//to be change
if (itemScript.currCategory == ItemCategory.LIGHT)
itemRidibody.AddForce(vec * 0.3f);
if (itemScript.currCategory == ItemCategory.MEDIUM)
itemRidibody.AddForce(vec * 0.75f);
if (itemScript.currCategory == ItemCategory.HEAVY)
itemRidibody.AddForce(vec);
}
itemRidibody.LinearVelocity += pc.rb.LinearVelocity;
ResetItemObject();
throwItem = true;
timer = 0.0f;
}
@ -96,8 +88,8 @@ public class PickAndThrow : Script
{
pc.holdItem = false;
inRange = false;
itemRidibody.IsGravityEnabled = true;
itemCollider.Enabled = true;
itemRidigBody.IsGravityEnabled = true;
itemCollider.GetCollisionShape(0).IsTrigger = false;
ResetItemObject();
}
@ -111,9 +103,9 @@ public class PickAndThrow : Script
}
else if (!pc.holdItem)
{
itemRidibody.IsGravityEnabled = true;
itemCollider.Enabled = true;
{
itemRidigBody.IsGravityEnabled = true;
itemCollider.GetCollisionShape(0).IsTrigger = false;
}
}
@ -129,11 +121,27 @@ public class PickAndThrow : Script
protected override void fixedUpdate()
{
if (throwItem && itemRidigBody && pc)
{
if (itemScript)
{
Vector3 vec = new Vector3(throwForce.x * lastXDir, throwForce.y, throwForce.z * lastZDir);
if (itemScript.currCategory == ItemCategory.LIGHT)
itemRidigBody.AddForce(vec * 0.2f);
if (itemScript.currCategory == ItemCategory.MEDIUM)
itemRidigBody.AddForce(vec * 0.75f);
if (itemScript.currCategory == ItemCategory.HEAVY)
itemRidigBody.AddForce(vec);
}
itemRidigBody.LinearVelocity += pc.rb.LinearVelocity;
throwItem = false;
ResetItemObject();
}
}
private void ResetItemObject()
{
itemRidibody = null;
itemRidigBody = null;
itemTransform = null;
itemCollider = null;
itemScript = null;
@ -143,16 +151,14 @@ public class PickAndThrow : Script
private void RetrieveItemComponets()
{
//get the transform of the given item
if (item.GetScript<Item>() && !itemTransform && !itemRidibody )
if (item.GetScript<Item>() && !itemTransform && !itemRidigBody)
{
itemRidibody = item.GetComponent<RigidBody>();
if (!itemRidibody)
itemRidigBody = item.GetComponent<RigidBody>();
if (!itemRidigBody)
Debug.Log("Item rb EMPTY");
else
{
itemRidibody.IsGravityEnabled = false;
itemRidibody.LinearVelocity = Vector3.Zero;
itemRidibody.AngularVelocity = Vector3.Zero;
itemRidigBody.IsGravityEnabled = false;
}
itemTransform = item.GetComponent<Transform>();
@ -168,7 +174,7 @@ public class PickAndThrow : Script
Debug.Log("Item collider EMPTY");
else
{
itemCollider.Enabled = false;
itemCollider.GetCollisionShape(0).IsTrigger = true;
}
itemScript = item.GetScript<Item>();

View File

@ -15,6 +15,8 @@ namespace SHADE_Scripting
public float turnSpeedPitch = 0.3f;
public float turnSpeedYaw = 0.5f;
public float pitchClamp = 45.0f;
public bool inverseXControls = false;
public bool inverseYControls = false;
protected override void awake()
{
@ -42,8 +44,15 @@ namespace SHADE_Scripting
if (arm)
{
Vector2 vel = Input.GetMouseVelocity();
arm.Pitch -= vel.y * turnSpeedPitch * Time.DeltaTimeF;
arm.Yaw += vel.x * turnSpeedYaw * Time.DeltaTimeF;
if(inverseYControls)
arm.Pitch -= vel.y * turnSpeedPitch * Time.DeltaTimeF;
else
arm.Pitch += vel.y * turnSpeedPitch * Time.DeltaTimeF;
if (inverseXControls)
arm.Yaw -= vel.x * turnSpeedYaw * Time.DeltaTimeF;
else
arm.Yaw += vel.x * turnSpeedYaw * Time.DeltaTimeF;
if (arm.Pitch > pitchClamp)
{

View File

@ -79,11 +79,13 @@ public class GameManager : Script
if (timer > 0 && totalItemCount <= 0)
{
currGameState = GameState.WIN;
Audio.StopAllSounds();
SceneManager.ChangeScene(winScene);
}
else if(timer < 0)
{
currGameState = GameState.LOSE;
Audio.StopAllSounds();
SceneManager.ChangeScene(loseScene);
}
}
@ -93,14 +95,17 @@ public class GameManager : Script
{
if (Input.GetKeyDown(Input.KeyCode.F1))
{
Audio.StopAllSounds();
SceneManager.ChangeScene(loseScene);
}
if (Input.GetKeyDown(Input.KeyCode.F2))
{
Audio.StopAllSounds();
SceneManager.ChangeScene(winScene);
}
if (Input.GetKeyDown(Input.KeyCode.Escape))
{
Audio.StopAllSounds();
SceneManager.ChangeScene(97158628);
}
}

View File

@ -18,12 +18,10 @@ public class Item : Script
protected override void awake()
{
rb = GetComponent<RigidBody>();
if (rb)
{
rb.FreezeRotationX = false;
rb.FreezeRotationY = false;
rb.FreezeRotationZ = false;
}
}
protected override void update()
{
}
protected override void onCollisionEnter(CollisionInfo info)