Scene Changes and bug fixes #431
|
@ -37,9 +37,15 @@ public class PickAndThrow : Script
|
|||
[NonSerialized]
|
||||
private TweenThread camArmTween;
|
||||
[NonSerialized]
|
||||
private TweenThread foodTween;
|
||||
private TweenThreadVec3 offSetCamTween;
|
||||
[NonSerialized]
|
||||
private TweenThreadVec3 foodTween;
|
||||
|
||||
public float tweenDuration = 0.3f;
|
||||
public float tweenPickUpDuration = 0.5f;
|
||||
public float tweenAimDuration = 0.3f;
|
||||
private bool createFoodTween = true;
|
||||
private bool createCamTween = true;
|
||||
private bool camTweenUpdate = false;
|
||||
|
||||
protected override void awake()
|
||||
{
|
||||
|
@ -76,21 +82,32 @@ public class PickAndThrow : Script
|
|||
CalculateDir();
|
||||
CastRay();
|
||||
|
||||
if (camTweenUpdate)
|
||||
{
|
||||
pc.camArm.TargetOffset = offSetCamTween.GetValue();
|
||||
pc.camArm.ArmLength = camArmTween.GetValue();
|
||||
|
||||
if (offSetCamTween.IsCompleted() && camArmTween.IsCompleted())
|
||||
camTweenUpdate = false;
|
||||
}
|
||||
|
||||
if (pc && itemRidigBody && itemTransform && itemCollider)
|
||||
{
|
||||
if (pc.holdItem)
|
||||
{
|
||||
itemTransform.LocalPosition = raccoonHoldLocation.GlobalPosition;
|
||||
TweenFood();
|
||||
itemTransform.LocalRotation = pc.tranform.LocalRotation;
|
||||
itemRidigBody.ClearForces();
|
||||
itemRidigBody.ClearTorque();
|
||||
itemRidigBody.LinearVelocity = Vector3.Zero;
|
||||
itemRidigBody.AngularVelocity = Vector3.Zero;
|
||||
|
||||
if (Input.GetMouseButtonDown(Input.MouseCode.LeftButton))
|
||||
{
|
||||
pc.isAiming = true;
|
||||
pc.camArm.ArmLength = aimingLength;
|
||||
prevTargetOffSet = pc.camArm.TargetOffset;
|
||||
pc.camArm.TargetOffset = cameraArmOffSet;
|
||||
TweenAimCamArm();
|
||||
//pc.camArm.TargetOffset = cameraArmOffSet;
|
||||
//pc.camArm.ArmLength = aimingLength;
|
||||
pc.cam.FOV = Settings.cameraFOV + 5;
|
||||
}
|
||||
|
||||
|
@ -100,11 +117,12 @@ public class PickAndThrow : Script
|
|||
itemRidigBody.IsGravityEnabled = true;
|
||||
itemCollider.GetCollisionShape(0).IsTrigger = false;
|
||||
pc.isAiming = false;
|
||||
createCamTween = true;
|
||||
pc.camArm.TargetOffset = prevTargetOffSet;
|
||||
pc.camArm.ArmLength = tpc.armLength;
|
||||
pc.cam.FOV = Settings.cameraFOV;
|
||||
if (tpc)
|
||||
pc.camArm.ArmLength = tpc.armLength;
|
||||
pc.holdItem = false;
|
||||
createFoodTween = true;
|
||||
inRange = false;
|
||||
throwItem = true;
|
||||
PlayThrowAnimation();
|
||||
|
@ -114,6 +132,7 @@ public class PickAndThrow : Script
|
|||
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && !pc.isAiming)
|
||||
{
|
||||
pc.holdItem = false;
|
||||
createFoodTween = true;
|
||||
inRange = false;
|
||||
itemRidigBody.IsGravityEnabled = true;
|
||||
itemCollider.GetCollisionShape(0).IsTrigger = false;
|
||||
|
@ -124,9 +143,10 @@ public class PickAndThrow : Script
|
|||
{
|
||||
pc.isAiming = false;
|
||||
pc.cam.FOV = Settings.cameraFOV;
|
||||
createCamTween = true;
|
||||
//TweenAimCamArm(false);
|
||||
pc.camArm.TargetOffset = prevTargetOffSet;
|
||||
if (tpc)
|
||||
pc.camArm.ArmLength = tpc.armLength;
|
||||
pc.camArm.ArmLength = tpc.armLength;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -237,9 +257,11 @@ public class PickAndThrow : Script
|
|||
Vector3 playerRayPos = pc.tranform.GlobalPosition;
|
||||
playerRayPos.y += rayHeight;
|
||||
dirNor.Normalise();
|
||||
List<RaycastHit> rayList1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance, false, (ushort)65535);
|
||||
List<RaycastHit> rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false, (ushort)65535);
|
||||
List<RaycastHit> rayList3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f, false, (ushort)65535);
|
||||
List<RaycastHit> rayList1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(25.0f))), rayDistance, false, (ushort)65535);
|
||||
List<RaycastHit> rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-25.0f))), rayDistance, false, (ushort)65535);
|
||||
List<RaycastHit> rayList3 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(12.5f))), rayDistance, false, (ushort)65535);
|
||||
List<RaycastHit> rayList4 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-12.5f))), rayDistance, false, (ushort)65535);
|
||||
List<RaycastHit> rayList5 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance , false, (ushort)65535);
|
||||
|
||||
if (rayList1.Count > 0)
|
||||
{
|
||||
|
@ -259,6 +281,18 @@ public class PickAndThrow : Script
|
|||
inRange = CheckForItem(ray3);
|
||||
return;
|
||||
}
|
||||
else if (rayList4.Count > 0)
|
||||
{
|
||||
RaycastHit ray4 = rayList4[0];
|
||||
inRange = CheckForItem(ray4);
|
||||
return;
|
||||
}
|
||||
else if (rayList5.Count > 0)
|
||||
{
|
||||
RaycastHit ray5 = rayList5[0];
|
||||
inRange = CheckForItem(ray5);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
inRange = false;
|
||||
|
@ -394,4 +428,31 @@ public class PickAndThrow : Script
|
|||
}
|
||||
}
|
||||
|
||||
private void TweenFood()
|
||||
{
|
||||
if (createFoodTween)
|
||||
{
|
||||
foodTween = TweenManager.CreateTweenThreadVec3(tweenPickUpDuration, itemTransform.LocalPosition, raccoonHoldLocation.GlobalPosition, EASING_METHOD.EASE_IN_SINE);
|
||||
createFoodTween = false;
|
||||
}
|
||||
|
||||
itemTransform.LocalPosition = foodTween.GetValue();
|
||||
|
||||
if (foodTween.IsCompleted())
|
||||
itemTransform.LocalPosition = raccoonHoldLocation.GlobalPosition;
|
||||
|
||||
}
|
||||
|
||||
private void TweenAimCamArm()
|
||||
{
|
||||
if (createCamTween)
|
||||
{
|
||||
offSetCamTween = TweenManager.CreateTweenThreadVec3(tweenAimDuration, pc.camArm.TargetOffset, cameraArmOffSet, EASING_METHOD.EASE_IN_SINE);
|
||||
camArmTween = TweenManager.CreateTweenThread(tweenPickUpDuration, pc.camArm.ArmLength, aimingLength, EASING_METHOD.EASE_IN_SINE);
|
||||
camTweenUpdate = true;
|
||||
Debug.Log($"camera arm lenght: {pc.camArm.ArmLength} aimingLength:{aimingLength} ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -181,10 +181,15 @@ public class PlayerController : Script
|
|||
{
|
||||
cam = GetComponentInChildren<Camera>();
|
||||
if (pat)
|
||||
{
|
||||
cam.FOV = Settings.cameraFOV;
|
||||
}
|
||||
}
|
||||
if(!camArm)
|
||||
if (!camArm)
|
||||
{
|
||||
camArm = GetComponentInChildren<CameraArm>();
|
||||
pat.prevTargetOffSet = camArm.TargetOffset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue