This commit is contained in:
Le Duc Anh
2025-09-08 16:29:40 +07:00
9 changed files with 255 additions and 76 deletions
+23 -23
View File
@@ -93,32 +93,32 @@ public class CharacterCtrl : MonoBehaviour
playerVelocity.y = 0f;
}
float x = joystick.Horizontal;
float z = joystick.Vertical;
//float x = joystick.Horizontal;
//float z = joystick.Vertical;
Vector3 move = new Vector3(x, 0, z);
move = Vector3.ClampMagnitude(move, 1f);
//Vector3 move = new Vector3(x, 0, z);
//move = Vector3.ClampMagnitude(move, 1f);
if (move != Vector3.zero)
{
transform.forward = move;
if (isRun)
{
SetAnimRun();
}
else
{
SetAnimWalk();
}
}
else
{
SetAnimIdle();
}
//if (move != Vector3.zero)
//{
// transform.forward = move;
// if (isRun)
// {
// SetAnimRun();
// }
// else
// {
// SetAnimWalk();
// }
//}
//else
//{
// SetAnimIdle();
//}
playerVelocity.y += gravityValue * Time.deltaTime;
Vector3 finalMove = (move * playerSpeed) + (playerVelocity.y * Vector3.up);
controller.Move(finalMove * Time.deltaTime);
//playerVelocity.y += gravityValue * Time.deltaTime;
//Vector3 finalMove = (move * playerSpeed) + (playerVelocity.y * Vector3.up);
//controller.Move(finalMove * Time.deltaTime);
}
+29
View File
@@ -1,18 +1,47 @@
using CSNetwork.Protocols.RPCData;
using System.Data;
using Unity.VisualScripting;
using UnityEngine;
public class GameController : MonoBehaviour
{
private static GameController instance;
[SerializeField] private CharacterCtrl characterPrefab;
[SerializeField] private Transform ground;
Camera camera;
public static GameController Instance
{
get
{
if (instance == null)
{
instance = new GameController();
}
return instance;
}
}
private void Awake()
{
if(instance == null)
{
instance = this;
}
}
private void Start()
{
camera = Camera.main;
}
public void Log(string s)
{
Debug.LogError(s);
}
public void InitCharacter(RoleInfo roleInfo)
{
CharacterCtrl character = Instantiate(characterPrefab, transform);