Compare commits

..

1 Commits

Author SHA1 Message Date
6ef2b47819 feat: Add custom character controller and update Trooper prefab
This commit introduces a new custom character controller and updates the Trooper prefab with the following changes:

- Add a new `CapsuleColliderCast` script to the custom character controller
- Update the near clip plane of the Trooper's camera to 0.01 for better visibility
- Update the package reference for the custom character controller to use the new package name `com.robotfireopenteam.customcharactercontroller`
- Add a new component to the Trooper's Camera GameObject

These changes are aimed at improving the character controller functionality and visual quality of the Trooper prefab.
2025-05-06 23:09:53 +03:00
14 changed files with 2196 additions and 6 deletions

BIN
Assets/Models/Trooper3.fbx Normal file

Binary file not shown.

View File

@ -0,0 +1,107 @@
fileFormatVersion: 2
guid: e02dff03dafb8054cb8fde8c5bc701e2
ModelImporter:
serializedVersion: 22200
internalIDToNameTable: []
externalObjects: {}
materials:
materialImportMode: 2
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,107 @@
fileFormatVersion: 2
guid: cac0cc65c22082a45a4e2c1c334b4bed
ModelImporter:
serializedVersion: 22200
internalIDToNameTable: []
externalObjects: {}
materials:
materialImportMode: 2
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9837b2b8dd7f213468aa67a089daafa9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
using UnityEngine;
public class CapsuleColliderCast : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 427ea62952a5df34f8f4b800a64ddf04

View File

@ -0,0 +1,212 @@
using System;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
public class Character : NetworkBehaviour
{
/// <summary>
/// Kinematic character controller to move the player character
/// as a kinematic object
/// </summary>
[Header("Input Controls")]
/// <summary>
/// Action reference for moving the player.
/// </summary>
[Tooltip("Action reference for moving the player")]
[SerializeField]
private InputActionReference moveAction;
/// <summary>
/// Action reference for jumping.
/// </summary>
[Tooltip("Action reference for moving the player")]
[SerializeField]
private InputActionReference jumpAction;
/// <summary>
/// Action reference for sprinting.
/// </summary>
[Tooltip("Action reference for moving the player")]
[SerializeField]
private InputActionReference sprintAction;
[Header("Ground Checking")]
/// <summary>
/// Distance to ground at which player is considered grounded
/// </summary>
[Tooltip("Distance from ground at which a player is considered standing on the ground")]
[SerializeField]
private float groundedDistance = 0.01f;
/// <summary>
/// Distance to ground at which player is considered standing on something
/// </summary>
[Tooltip("Distance to ground at which player is considered standing on something")]
[SerializeField]
private float standingDistance = 0.1f;
/// <summary>
/// Distance to check player distance to ground
/// </summary>
[Tooltip("Distance to draw rays down when checking if player is grounded")]
[SerializeField]
private float groundCheckDistance = 5f;
/// <summary>
/// Maximum angle at which the player can walk (in degrees)
/// </summary>
[Tooltip("Maximum angle at which the player can walk")]
[SerializeField]
[Range(0, 90)]
private float maxWalkAngle = 60f;
/// <summary>
/// Direction and strength of gravity
/// </summary>
[Tooltip("Direction and strength of gravity in units per second squared")]
[SerializeField]
private Vector3 gravity = new Vector3(0, -9.807f, 0);
[Header("Motion Settings")]
/// <summary>
/// Speed of player movement when walking.
/// </summary>
[Tooltip("Speed of player when walking")]
[SerializeField]
private float walkingSpeed = 7.5f;
/// <summary>
/// Speed of player when sprinting.
/// </summary>
[Tooltip("Speed of player when sprinting")]
[SerializeField]
private float sprintSpeed = 10.0f;
[Header("Objects")]
[SerializeField] protected CharacterController _characterController;
[SerializeField] protected Camera _mainCam;
[SerializeField] protected AudioListener _audioListener;
[SerializeField] protected Weapon _weapon;
[Header("Input Actions")]
[SerializeField] protected PlayerInput _playerInput;
private void Awake()
{
_characterController = GetComponent<CharacterController>();
_playerInput = GetComponent<PlayerInput>();
_audioListener = GetComponentInChildren<AudioListener>();
}
// Public Inputs Methods
// public void OnMove(InputAction.CallbackContext context)
// {
// _moveInput = context.ReadValue<Vector2>();
// }
// public void OnLook(InputAction.CallbackContext context)
// {
// _lookInput = context.ReadValue<Vector2>();
// }
// public void OnSprint(InputAction.CallbackContext context)
// {
// if (context.performed)
// {
// Debug.Log("Running");
// _speedMultiplier = _sprintMultiplier;
// }
// else
// {
// _speedMultiplier = 1f;
// }
// }
// public void OnJump(InputAction.CallbackContext context)
// {
// if (context.performed)
// {
// JumpServerRPC();
// }
// }
// public void OnAttack(InputAction.CallbackContext context)
// {
// if (context.performed)
// {
// ShootServerRPC();
// }
// }
// public void OnAim(InputAction.CallbackContext context)
// {
// if (context.performed)
// {
// AimServerRPC();
// }
// }
// public void OnCrouch(InputAction.CallbackContext context)
// {
// if (context.performed)
// {
// CrouchServerRPC();
// }
// }
// public void OnInteract(InputAction.CallbackContext context)
// {
// if (context.performed)
// {
// InteractServerRPC();
// }
// }
// Networking Staff
// [ServerRpc]
// protected void JumpServerRPC()
// {
// if (_characterController.isGrounded)
// {
// Debug.Log($"Jump triggered. Owner: {OwnerClientId}");
// }
// }
// [ServerRpc]
// protected void ShootServerRPC()
// {
// Debug.Log($"Shooting triggered. Owner: {OwnerClientId}");
// _weapon.Shooting();
// }
// [ServerRpc]
// protected void AimServerRPC()
// {
// Debug.Log($"Aim triggered. Owner: {OwnerClientId}");
// }
// [ServerRpc]
// protected void CrouchServerRPC()
// {
// Debug.Log($"Crouch triggered. Owner: {OwnerClientId}");
// }
// [ServerRpc]
// protected void InteractServerRPC()
// {
// Debug.Log($"Interact triggered. Owner: {OwnerClientId}");
// }
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0fece460808cf3d45b461b8bd4230eb9

View File

@ -11,11 +11,11 @@ public class PlayerModel : NetworkBehaviour
// Исключаем слой ModelLocal из рендеринга для mainCamera // Исключаем слой ModelLocal из рендеринга для mainCamera
if (IsLocalPlayer) if (IsLocalPlayer)
{ {
SetLayerRecursively(gameObject, LayerMask.NameToLayer("ModelLocal")); SetLayerRecursively(gameObject, LayerMask.NameToLayer("ModelRemote"));
} }
else else
{ {
SetLayerRecursively(gameObject, LayerMask.NameToLayer("ModelRemote")); SetLayerRecursively(gameObject, LayerMask.NameToLayer("ModelLocal"));
} }
Debug.Log($"NetworkObject ID: {NetworkObjectId} RobotModel's LayerMask: " + gameObject.layer); Debug.Log($"NetworkObject ID: {NetworkObjectId} RobotModel's LayerMask: " + gameObject.layer);
} }

View File

@ -0,0 +1,24 @@
{
"name": "com.robotfireopenteam.customcharactercontroller",
"version": "1.0.0",
"displayName": "Custom Character Controller",
"description": "Open Custom Kinematic Controller for making robots for RobotFire Unity Game",
"unity": "2019.1",
"documentationUrl": "https://robotfire.aderk.tech/docs",
"changelogUrl": "https://robotfire.aderk.tech/changelog.html",
"licensesUrl": "https://robotfire.aderk.tech/licensing.html",
"dependencies": {
},
"keywords": [
"library",
"utility",
"controller"
],
"author": {
"name": "Konstantin Ader",
"email": "dev@aderk.tech",
"url": "https://robotfire.aderk.tech"
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a2740a0fc4f8f9145aeda68e9065739c
PackageManifestImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,8 +7,8 @@
"dependencies": {}, "dependencies": {},
"url": "https://packages.unity.com" "url": "https://packages.unity.com"
}, },
"com.twsp.robotfire.customcharactercontroller": { "com.robotfireopenteam.customcharactercontroller": {
"version": "file:com.twsp.robotfire.customcharactercontroller", "version": "file:custom-character-controller",
"depth": 0, "depth": 0,
"source": "embedded", "source": "embedded",
"dependencies": {} "dependencies": {}