-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
4,115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"recommendations": [ | ||
"visualstudiotoolsforunity.vstuc" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.