Skip to content

Commit

Permalink
ngo file all commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MyKhode committed Mar 30, 2024
1 parent 5fcb382 commit 3303781
Show file tree
Hide file tree
Showing 51 changed files with 4,115 additions and 0 deletions.
5 changes: 5 additions & 0 deletions NGO_Setup/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"visualstudiotoolsforunity.vstuc"
]
}
10 changes: 10 additions & 0 deletions NGO_Setup/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Unity",
"type": "vstuc",
"request": "attach"
}
]
}
55 changes: 55 additions & 0 deletions NGO_Setup/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"files.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/.gitmodules": true,
"**/*.booproj": true,
"**/*.pidb": true,
"**/*.suo": true,
"**/*.user": true,
"**/*.userprefs": true,
"**/*.unityproj": true,
"**/*.dll": true,
"**/*.exe": true,
"**/*.pdf": true,
"**/*.mid": true,
"**/*.midi": true,
"**/*.wav": true,
"**/*.gif": true,
"**/*.ico": true,
"**/*.jpg": true,
"**/*.jpeg": true,
"**/*.png": true,
"**/*.psd": true,
"**/*.tga": true,
"**/*.tif": true,
"**/*.tiff": true,
"**/*.3ds": true,
"**/*.3DS": true,
"**/*.fbx": true,
"**/*.FBX": true,
"**/*.lxo": true,
"**/*.LXO": true,
"**/*.ma": true,
"**/*.MA": true,
"**/*.obj": true,
"**/*.OBJ": true,
"**/*.asset": true,
"**/*.cubemap": true,
"**/*.flare": true,
"**/*.mat": true,
"**/*.meta": true,
"**/*.prefab": true,
"**/*.unity": true,
"build/": true,
"Build/": true,
"Library/": true,
"library/": true,
"obj/": true,
"Obj/": true,
"ProjectSettings/": true,
"temp/": true,
"Temp/": true
},
"dotnet.defaultSolution": "NGO_Setup.sln"
}
16 changes: 16 additions & 0 deletions NGO_Setup/Assets/DefaultNetworkPrefabs.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e651dbb3fbac04af2b8f5abf007ddc23, type: 3}
m_Name: DefaultNetworkPrefabs
m_EditorClassIdentifier:
IsDefault: 1
List: []
8 changes: 8 additions & 0 deletions NGO_Setup/Assets/DefaultNetworkPrefabs.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions NGO_Setup/Assets/PlayerController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Unity.Netcode;
using UnityEngine;

[RequireComponent(typeof(CharacterController))]
public class PlayerController : NetworkBehaviour
{
[Header("Game Components")]
[SerializeField] private Camera playerCamera;
[SerializeField] private CharacterController characterController;

[Header("Game Variables")]
[SerializeField] private float walkSpeed = 15f;
[SerializeField] private float runSpeed = 25f;
[SerializeField] private float jumpPower = 15f;
[SerializeField] private float gravity = 10f;
[SerializeField] private float lookSpeed = 3.5f;
[SerializeField] private float lookXLimit = 45f;

private Vector3 moveDirection = Vector3.zero;
private float rotationX = 0f;
private float verticalVelocity;

public override void OnNetworkSpawn()
{
// gameObject.transform.position = new Vector3(Random.Range(-10f, 10f), 5f, Random.Range(-10f, 10f));
}

private void Start()
{
Debug.Log("FPS controller => is owner = " + IsOwner + ": is local player + " + IsLocalPlayer + " : is server = " + IsServer);
}

private void Update()
{
if (!IsOwner || !IsLocalPlayer || !Application.isFocused)
{
playerCamera.enabled = false;
return;
}

playerCamera.enabled = true;
Player_Movement();
}

private void Player_Movement()
{
Vector3 forward = transform.TransformDirection(Vector3.forward);
Vector3 right = transform.TransformDirection(Vector3.right);


bool isRunning = Input.GetKey(KeyCode.LeftShift);
float curSpeedX = (isRunning ? runSpeed : walkSpeed) * Input.GetAxis("Vertical");
float curSpeedY = (isRunning ? runSpeed : walkSpeed) * Input.GetAxis("Horizontal");

moveDirection = (forward * curSpeedX) + (right * curSpeedY);

if (characterController.isGrounded)
{
if (Input.GetButtonDown("Jump"))
{
verticalVelocity = jumpPower;
}
}
else
{
verticalVelocity -= gravity * Time.deltaTime;
}

moveDirection.y = verticalVelocity;
characterController.Move(moveDirection * Time.deltaTime);

rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
}
}
11 changes: 11 additions & 0 deletions NGO_Setup/Assets/PlayerController.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3303781

Please sign in to comment.