Running bug fixed
This commit is contained in:
parent
5cd7de4d3b
commit
4a2f70b3af
@ -1160,7 +1160,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: -8679921383154817045, guid: 2c04b8261d21a8e45852e1e050858e41, type: 3}
|
- target: {fileID: -8679921383154817045, guid: 2c04b8261d21a8e45852e1e050858e41, type: 3}
|
||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
value: 0.69
|
value: 0.57
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: -8679921383154817045, guid: 2c04b8261d21a8e45852e1e050858e41, type: 3}
|
- target: {fileID: -8679921383154817045, guid: 2c04b8261d21a8e45852e1e050858e41, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
@ -1318,8 +1318,8 @@ BoxCollider:
|
|||||||
m_ProvidesContacts: 0
|
m_ProvidesContacts: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
m_Size: {x: 0.20475894, y: 0.3609593, z: 0.3661172}
|
m_Size: {x: 0.20475894, y: 0.3609593, z: 0.19027588}
|
||||||
m_Center: {x: -0.00010097027, y: 0.16952038, z: 0.036941394}
|
m_Center: {x: -0.00010097027, y: 0.16952038, z: 0.12486206}
|
||||||
--- !u!54 &1704108066
|
--- !u!54 &1704108066
|
||||||
Rigidbody:
|
Rigidbody:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1596,8 +1596,8 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1787069559}
|
m_GameObject: {fileID: 1787069559}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
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: 1.1700001, z: 67.131}
|
m_LocalPosition: {x: 0, y: 0.89, z: 67.131}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
|
@ -12,7 +12,7 @@ public class ChaseCameraController : MonoBehaviour
|
|||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
Vector3 targetPos = player.position + offset;
|
Vector3 targetPos = player.position + offset;
|
||||||
transform.position = Vector3.Lerp(transform.position, targetPos, followSpeed * Time.deltaTime);
|
transform.position = Vector3.Lerp( transform.position, targetPos, followSpeed * Time.deltaTime);
|
||||||
|
|
||||||
// transform.LookAt(player.position + Vector3.up * 1.5f);
|
// transform.LookAt(player.position + Vector3.up * 1.5f);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class ChasePlayerController : MonoBehaviour
|
|||||||
currentLane--;
|
currentLane--;
|
||||||
|
|
||||||
if (Input.GetKeyDown(KeyCode.RightArrow) && currentLane < 2)
|
if (Input.GetKeyDown(KeyCode.RightArrow) && currentLane < 2)
|
||||||
currentLane--;
|
currentLane++;
|
||||||
|
|
||||||
if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
|
if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
|
||||||
Jump();
|
Jump();
|
||||||
@ -153,185 +153,3 @@ public class ChasePlayerController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//using DG.Tweening;
|
|
||||||
//using DG.Tweening.Plugins.Core;
|
|
||||||
//using DG.Tweening.Core;
|
|
||||||
//using DG.Tweening.Plugins.Options;
|
|
||||||
|
|
||||||
//using UnityEngine;
|
|
||||||
|
|
||||||
//public class ChasePlayerController : MonoBehaviour
|
|
||||||
//{
|
|
||||||
// public float moveSpeed = 5f;
|
|
||||||
// public float laneDistance = 2.5f; // Distance between lanes
|
|
||||||
// public float jumpForce = 7f;
|
|
||||||
// public float laneSwitchSpeed = 10f;
|
|
||||||
|
|
||||||
// private int currentLane = 1; // 0 = Left, 1 = Middle, 2 = Right
|
|
||||||
// private Rigidbody rb;
|
|
||||||
// private Animator animator;
|
|
||||||
// private bool isGrounded = true;
|
|
||||||
|
|
||||||
// private Vector3 targetPosition;
|
|
||||||
|
|
||||||
// private Vector2 startTouchPosition;
|
|
||||||
// private Vector2 endTouchPosition;
|
|
||||||
// private bool swipeDetected = false;
|
|
||||||
// private float minSwipeDistance = 50f; // Pixels
|
|
||||||
|
|
||||||
// void Start()
|
|
||||||
// {
|
|
||||||
// rb = GetComponent<Rigidbody>();
|
|
||||||
// animator = GetComponent<Animator>();
|
|
||||||
// targetPosition = transform.position;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void Update()
|
|
||||||
// {
|
|
||||||
// HandleInput();
|
|
||||||
// HandleSwipe(); // Add this
|
|
||||||
// HandleLaneSwitch();
|
|
||||||
// MoveForward();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void HandleInput()
|
|
||||||
// {
|
|
||||||
// // Keyboard controls (for testing in editor)
|
|
||||||
// if (Input.GetKeyDown(KeyCode.LeftArrow))
|
|
||||||
// {
|
|
||||||
// if (currentLane > 0)
|
|
||||||
// currentLane--;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (Input.GetKeyDown(KeyCode.RightArrow))
|
|
||||||
// {
|
|
||||||
// if (currentLane < 2)
|
|
||||||
// currentLane++;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
|
|
||||||
// {
|
|
||||||
// Jump();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void HandleSwipe()
|
|
||||||
// {
|
|
||||||
// if (Input.touchCount == 1)
|
|
||||||
// {
|
|
||||||
// Touch touch = Input.GetTouch(0);
|
|
||||||
|
|
||||||
// switch (touch.phase)
|
|
||||||
// {
|
|
||||||
// case TouchPhase.Began:
|
|
||||||
// startTouchPosition = touch.position;
|
|
||||||
// swipeDetected = true;
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case TouchPhase.Ended:
|
|
||||||
// if (swipeDetected)
|
|
||||||
// {
|
|
||||||
// endTouchPosition = touch.position;
|
|
||||||
// Vector2 swipe = endTouchPosition - startTouchPosition;
|
|
||||||
|
|
||||||
// if (swipe.magnitude >= minSwipeDistance)
|
|
||||||
// {
|
|
||||||
// float x = swipe.x;
|
|
||||||
// float y = swipe.y;
|
|
||||||
|
|
||||||
// if (Mathf.Abs(x) > Mathf.Abs(y))
|
|
||||||
// {
|
|
||||||
// // Horizontal swipe
|
|
||||||
// if (x > 0)
|
|
||||||
// {
|
|
||||||
// // Swipe Right
|
|
||||||
// if (currentLane < 2)
|
|
||||||
// currentLane++;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// // Swipe Left
|
|
||||||
// if (currentLane > 0)
|
|
||||||
// currentLane--;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// // Vertical swipe
|
|
||||||
// if (y > 0 && isGrounded)
|
|
||||||
// {
|
|
||||||
// // Swipe Up = Jump
|
|
||||||
// Jump();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// swipeDetected = false;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// void Jump()
|
|
||||||
// {
|
|
||||||
// if (!isGrounded) return;
|
|
||||||
|
|
||||||
// isGrounded = false;
|
|
||||||
// rb.velocity = Vector3.zero;
|
|
||||||
// rb.useGravity = false;
|
|
||||||
// float jumpPower = 0.6f; // how high the jump goes
|
|
||||||
// float jumpDuration = 1.6f; // total jump time
|
|
||||||
// int numJumps = 1;
|
|
||||||
|
|
||||||
// // Predict how far the character will move forward during the jump
|
|
||||||
// float forwardDisplacement = moveSpeed * jumpDuration;
|
|
||||||
|
|
||||||
// Vector3 jumpTarget = rb.position + Vector3.back * forwardDisplacement;
|
|
||||||
|
|
||||||
// rb.DOJump(
|
|
||||||
// jumpTarget,
|
|
||||||
// jumpPower,
|
|
||||||
// numJumps,
|
|
||||||
// jumpDuration
|
|
||||||
// )
|
|
||||||
// .SetEase(Ease.Linear)
|
|
||||||
// .OnStart(() =>
|
|
||||||
// {
|
|
||||||
// if (animator != null) animator.SetTrigger("Jump");
|
|
||||||
// })
|
|
||||||
// .OnComplete(() =>
|
|
||||||
// {
|
|
||||||
// isGrounded = true;
|
|
||||||
// if (animator != null) animator.SetTrigger("Run");
|
|
||||||
// rb.useGravity = true;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //void Jump()
|
|
||||||
// //{
|
|
||||||
// // rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
|
|
||||||
// // isGrounded = false;
|
|
||||||
// // if (animator != null) animator.SetTrigger("Jump");
|
|
||||||
// //}
|
|
||||||
|
|
||||||
// void HandleLaneSwitch()
|
|
||||||
// {
|
|
||||||
// float targetX = (currentLane - 1) * laneDistance;
|
|
||||||
// targetPosition = new Vector3(targetX, transform.position.y, transform.position.z);
|
|
||||||
// transform.position = Vector3.Lerp(transform.position, targetPosition, laneSwitchSpeed * Time.deltaTime);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void MoveForward()
|
|
||||||
// {
|
|
||||||
// transform.Translate(Vector3.back * moveSpeed * Time.deltaTime);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void OnCollisionEnter(Collision collision)
|
|
||||||
// {
|
|
||||||
// if (collision.gameObject.CompareTag("Ground"))
|
|
||||||
// {
|
|
||||||
// isGrounded = true;
|
|
||||||
// if (animator != null) animator.SetTrigger("Run");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user