Tweak movement
This commit is contained in:
parent
5fd67e0c6a
commit
2dcea14729
@ -240,6 +240,24 @@ MonoBehaviour:
|
|||||||
DisableInput: 0
|
DisableInput: 0
|
||||||
SyncInterval: 0.5
|
SyncInterval: 0.5
|
||||||
MovementUpdateInterval: 0.03
|
MovementUpdateInterval: 0.03
|
||||||
|
--- !u!114 &3537472584083277103
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7808238467771803924}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 22a7da1b361417640853a9cdcde28400, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
Player: {fileID: 7626229210202316125}
|
||||||
|
InterpolationSpeed: 5
|
||||||
|
YawDegrees: 4
|
||||||
|
PitchDegrees: 4
|
||||||
|
RollDegrees: 6
|
||||||
|
RotationThreshold: 5
|
||||||
--- !u!1 &8414821799312552490
|
--- !u!1 &8414821799312552490
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -817,3 +835,8 @@ Transform:
|
|||||||
m_CorrespondingSourceObject: {fileID: 4833458671639168932, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
m_CorrespondingSourceObject: {fileID: 4833458671639168932, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||||
m_PrefabInstance: {fileID: 8134536652936637724}
|
m_PrefabInstance: {fileID: 8134536652936637724}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!1 &7808238467771803924 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 2071588178488902664, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 8134536652936637724}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
@ -109,7 +109,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1607323028047207915}
|
m_GameObject: {fileID: 1607323028047207915}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: -0.02, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 4103164600241655739}
|
- {fileID: 4103164600241655739}
|
||||||
@ -508,7 +508,7 @@ MonoBehaviour:
|
|||||||
GroundCastLength: 0.2
|
GroundCastLength: 0.2
|
||||||
GroundLayer:
|
GroundLayer:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Bits: 11009
|
m_Bits: 10497
|
||||||
ShowGroundCast: 0
|
ShowGroundCast: 0
|
||||||
ShowMoveVector: 0
|
ShowMoveVector: 0
|
||||||
--- !u!1 &7391558913556166741
|
--- !u!1 &7391558913556166741
|
||||||
|
@ -13,7 +13,7 @@ MonoBehaviour:
|
|||||||
m_Name: Crouching
|
m_Name: Crouching
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
TargetVelocity: 6
|
TargetVelocity: 6
|
||||||
StopVelocity: 3
|
StopVelocity: 4
|
||||||
Acceleration: 20
|
Acceleration: 20
|
||||||
AirAcceleration: 15
|
AirAcceleration: 15
|
||||||
Friction: 20
|
Friction: 20
|
||||||
|
@ -13,8 +13,8 @@ MonoBehaviour:
|
|||||||
m_Name: Running
|
m_Name: Running
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
TargetVelocity: 11
|
TargetVelocity: 11
|
||||||
StopVelocity: 3
|
StopVelocity: 6
|
||||||
Acceleration: 7
|
Acceleration: 9
|
||||||
AirAcceleration: 5
|
AirAcceleration: 5
|
||||||
Friction: 6
|
Friction: 6
|
||||||
AirFriction: 2
|
AirFriction: 2
|
||||||
|
@ -14,10 +14,6 @@ namespace NeonTea.Quakeball.Animation {
|
|||||||
private Vector2 CurrentLean = Vector2.zero;
|
private Vector2 CurrentLean = Vector2.zero;
|
||||||
private Vector2 TargetLean = Vector2.zero;
|
private Vector2 TargetLean = Vector2.zero;
|
||||||
|
|
||||||
private void Awake() {
|
|
||||||
transform.parent = Player.Player.CameraRoot;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Update() {
|
private void Update() {
|
||||||
Vector2 LookDelta = Player.LookAction.ReadValue<Vector2>();
|
Vector2 LookDelta = Player.LookAction.ReadValue<Vector2>();
|
||||||
SetTarget(LookDelta.x, ref TargetLean.x);
|
SetTarget(LookDelta.x, ref TargetLean.x);
|
||||||
|
@ -21,9 +21,9 @@ namespace NeonTea.Quakeball.Animation {
|
|||||||
public Transform GunHandle;
|
public Transform GunHandle;
|
||||||
|
|
||||||
private Animator Animator;
|
private Animator Animator;
|
||||||
private float BodyYaw = 0;
|
|
||||||
private Transform BehindHand;
|
private Transform BehindHand;
|
||||||
private Transform FrontHand;
|
private Transform FrontHand;
|
||||||
|
private Transform Head;
|
||||||
|
|
||||||
private void Awake() {
|
private void Awake() {
|
||||||
foreach (Animator animator in Soldiers) {
|
foreach (Animator animator in Soldiers) {
|
||||||
@ -31,7 +31,7 @@ namespace NeonTea.Quakeball.Animation {
|
|||||||
}
|
}
|
||||||
Animator = Soldiers[(int)Model].GetComponent<Animator>();
|
Animator = Soldiers[(int)Model].GetComponent<Animator>();
|
||||||
Animator.gameObject.SetActive(true);
|
Animator.gameObject.SetActive(true);
|
||||||
HeadCollider.parent = TransformUtil.FindChildWithName(Animator.transform, "HEAD");
|
HeadCollider.parent = Head = TransformUtil.FindChildWithName(Animator.transform, "HEAD");
|
||||||
BehindHand = TransformUtil.FindChildWithName(Animator.transform, "HAND.R");
|
BehindHand = TransformUtil.FindChildWithName(Animator.transform, "HAND.R");
|
||||||
FrontHand = TransformUtil.FindChildWithName(Animator.transform, "HAND.L");
|
FrontHand = TransformUtil.FindChildWithName(Animator.transform, "HAND.L");
|
||||||
if (GunGluedToHand) {
|
if (GunGluedToHand) {
|
||||||
@ -48,6 +48,7 @@ namespace NeonTea.Quakeball.Animation {
|
|||||||
|
|
||||||
private void LateUpdate() {
|
private void LateUpdate() {
|
||||||
transform.localEulerAngles = new Vector3(0, Player.Yaw, 0);
|
transform.localEulerAngles = new Vector3(0, Player.Yaw, 0);
|
||||||
|
Head.localEulerAngles = new Vector3(Player.Pitch, 0, 0);
|
||||||
|
|
||||||
if (GunGluedToHand) {
|
if (GunGluedToHand) {
|
||||||
Vector3 GunOffset = GunHandle.position - Gun.position;
|
Vector3 GunOffset = GunHandle.position - Gun.position;
|
||||||
|
@ -133,19 +133,6 @@ namespace NeonTea.Quakeball.Players {
|
|||||||
return ShouldApply;
|
return ShouldApply;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The normal of the ground below the player. If there is no ground, it's <c>Vector3.up</c> by default.</summary>
|
|
||||||
public Vector3 GroundCast() {
|
|
||||||
RaycastHit Hit;
|
|
||||||
if (ShowGroundCast) {
|
|
||||||
Debug.DrawLine(FeetPosition, FeetPosition - Vector3.up, Color.red, 1f);
|
|
||||||
}
|
|
||||||
if (Physics.Raycast(FeetPosition, -Vector3.up, out Hit, GroundCastLength, GroundLayer)) {
|
|
||||||
return Hit.normal;
|
|
||||||
} else {
|
|
||||||
return Vector3.up;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Jump() {
|
public bool Jump() {
|
||||||
bool IsCoyoteTime = Time.time - GroundedTime <= CoyoteTime + PingBias;
|
bool IsCoyoteTime = Time.time - GroundedTime <= CoyoteTime + PingBias;
|
||||||
if (IsCoyoteTime || IsGrounded()) {
|
if (IsCoyoteTime || IsGrounded()) {
|
||||||
@ -249,6 +236,20 @@ namespace NeonTea.Quakeball.Players {
|
|||||||
return CharacterController.isGrounded && Vector3.Dot(GravitationalVelocity, Vector3.down) >= 0;
|
return CharacterController.isGrounded && Vector3.Dot(GravitationalVelocity, Vector3.down) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>The normal of the ground below the player. If there is no ground, it's <c>Vector3.up</c> by default.</summary>
|
||||||
|
private Vector3 GroundCast() {
|
||||||
|
RaycastHit hit;
|
||||||
|
Vector3 feetPosition = FeetPosition + transform.position + CharacterController.center + Vector3.down * CharacterController.height / 2;
|
||||||
|
if (ShowGroundCast) {
|
||||||
|
Debug.DrawLine(feetPosition, feetPosition - Vector3.up, Color.red, 1f);
|
||||||
|
}
|
||||||
|
if (Physics.Raycast(feetPosition, -Vector3.up, out hit, GroundCastLength, GroundLayer)) {
|
||||||
|
return hit.normal;
|
||||||
|
} else {
|
||||||
|
return Vector3.up;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void Awake() {
|
private void Awake() {
|
||||||
CharacterController = GetComponent<CharacterController>();
|
CharacterController = GetComponent<CharacterController>();
|
||||||
FeetPosition = transform.position + CharacterController.center - Vector3.up * (CharacterController.height / 2 + CharacterController.skinWidth / 2);
|
FeetPosition = transform.position + CharacterController.center - Vector3.up * (CharacterController.height / 2 + CharacterController.skinWidth / 2);
|
||||||
@ -278,7 +279,7 @@ namespace NeonTea.Quakeball.Players {
|
|||||||
|
|
||||||
bool FallingDown = Vector3.Dot(Vector3.down, GravitationalVelocity) > 0;
|
bool FallingDown = Vector3.Dot(Vector3.down, GravitationalVelocity) > 0;
|
||||||
if (Grounded && FallingDown) {
|
if (Grounded && FallingDown) {
|
||||||
GravitationalVelocity = Vector3.zero;
|
GravitationalVelocity = GroundCastLength * Vector3.down;
|
||||||
} else if (!Grounded) {
|
} else if (!Grounded) {
|
||||||
GravitationalVelocity += Physics.gravity * Time.deltaTime;
|
GravitationalVelocity += Physics.gravity * Time.deltaTime;
|
||||||
}
|
}
|
||||||
@ -305,22 +306,19 @@ namespace NeonTea.Quakeball.Players {
|
|||||||
Acceleration = Mathf.Min(Acceleration, MoveStyle.TargetVelocity - CurrentSpeed);
|
Acceleration = Mathf.Min(Acceleration, MoveStyle.TargetVelocity - CurrentSpeed);
|
||||||
GroundVelocity += FixedHeading * Acceleration;
|
GroundVelocity += FixedHeading * Acceleration;
|
||||||
|
|
||||||
Vector3 FinalMoveVector = GroundVelocity + GravitationalVelocity;
|
CharacterController.Move(GroundVelocity * Time.deltaTime);
|
||||||
CharacterController.Move(FinalMoveVector * Time.deltaTime);
|
CollisionFlags flags = CharacterController.Move(GravitationalVelocity * Time.deltaTime);
|
||||||
if (CharacterController.isGrounded) {
|
if (CharacterController.isGrounded) {
|
||||||
GroundedTime = Time.time;
|
GroundedTime = Time.time;
|
||||||
LatestGroundedY = transform.position.y;
|
LatestGroundedY = transform.position.y;
|
||||||
}
|
}
|
||||||
if (GravitationalVelocity.y > 0.1 && Mathf.Abs(CharacterController.velocity.y) < 0.1) {
|
if (GravitationalVelocity.y > 0.1 && Mathf.Abs(CharacterController.velocity.y) < 0.1) {
|
||||||
// Hit a roof while jumping
|
// Hit a roof while jumping, reset falling velocity downwards (same as "static gravity" when grounded)
|
||||||
GravitationalVelocity.y = 0;
|
GravitationalVelocity.y = GroundCastLength;
|
||||||
}
|
}
|
||||||
if (ShowMoveVector) {
|
if (ShowMoveVector) {
|
||||||
Debug.DrawLine(
|
Debug.DrawLine(transform.position + CharacterController.center, transform.position + CharacterController.center + GravitationalVelocity, Color.yellow, 1.0f);
|
||||||
transform.position + CharacterController.center,
|
Debug.DrawLine(transform.position + CharacterController.center, transform.position + CharacterController.center + GroundVelocity, Color.green, 1.0f);
|
||||||
transform.position + CharacterController.center + FinalMoveVector,
|
|
||||||
Color.green, 1.0f
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float TargetBobbiness = Grounded ? GroundVelocity.magnitude / MoveStyle.TargetVelocity : 0;
|
float TargetBobbiness = Grounded ? GroundVelocity.magnitude / MoveStyle.TargetVelocity : 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user