Coder Social home page Coder Social logo

gold-player's Introduction

Gold Player

A first-person player controller for Unity, built with being user-friendly and developer-friendly in mind.

๐Ÿ–ค Final Release

With the release of 1.7.0, I've decided to stop working on Gold Player. It has served well as a prototype (and even production ready!) player controller but it's stuck in legacy code that makes it hard to improve upon. Don't get me wrong, Gold Player is still very usable, it's just that I don't want to add new features to it or fix old issues. It's time to move on.

๐ŸŽ‡ Features

  • Optimized for speed and size
  • Walking, running (with optional stamina!), crouching, and jumping
  • Head bob and audio for footsteps, jumping, and landing
  • Moving platforms support
  • Easy to use functions
  • Very well documented code
  • Interaction component, UI component, graphics component, and animator component
  • Easy to integrate into multiplayer
  • Support for Unity's new Input System
  • Works with IL2CPP and fast enter play mode settings

๐Ÿ“ฆ Installation

Minimum supported Unity version: 2018.4

Package manager installation:

  1. Open the package manager in your project.
  2. Click the + button in the top left corner and click 'Add package from git'.
  3. Enter this URL: https://github.com/Hertzole/gold-player.git#package

or

  1. Open your manifest.json in YourGameFolder/Packages/.
  2. Add "se.hertzole.gold-player": "https://github.com/Hertzole/gold-player.git#package" to your dependencies list.
  3. Go back into Unity and it should resolve the packages and download Gold Player.

Unity package installation:

  1. Go to the releases tab and download the latest .unitypackage version.
  2. In Unity, import the package either by dragging it into your project or right-clicking in your project window - Import package - Custom package
  3. Include all the files in the editor/runtime folder. Components you don't want can be removed with script defines/project settings. You may remove examples if you want to.

Development branch:

There's a development branch you can use to get the latest features in package manager format. This branch may be unstable and features are not production ready!
In the package manager, enter
https://github.com/Hertzole/gold-player.git#dev-package instead.
In your manifest, enter
"se.hertzole.gold-player": "https://github.com/Hertzole/gold-player.git#dev-package" instead.

Updating:

Package manager version: Remove the package and add it again.
Unity package version: Remove the old project and reimport it.

๐Ÿ”จ Getting Started

After importing Gold Player into your project, the quickest way to get started is by creating the player using Create - 3D Object - Gold Player Controller. This will set up the player in a recommended way.
You can then explore all the options on the controller. You can also check out all the available components from the Add Component menu. They are under the Gold Player subcategory. You can also check out the examples that demonstrate specific features.

๐Ÿ“ƒ License

Gold Player is licensed under MIT. You can do whatever you want with it, but I'm not liable if it causes any damages.

๐Ÿ•น Screenshots and Testing

Play Example Level
You can play around in an example scene that showcases most of the features while also allowing you to modify the player at runtime.

The available editors: Editor

Buy Me a Coffee at ko-fi.com

gold-player's People

Contributors

fillefilip8 avatar hertzole avatar radiatoryang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gold-player's Issues

Can't get the player controller to even start without an error...

When I hit play after bringing the package in my game and setting up a simple input system I get this console error:

"NullReferenceException: Object reference not set to an instance of an object
Hertzole.GoldPlayer.PlayerCamera.MouseHandler (System.Single deltaTime) (at Library/PackageCache/se.hertzole.gold-player@eef1158b7d/Runtime/Core/Modules/PlayerCamera.cs:254)
Hertzole.GoldPlayer.PlayerCamera.OnUpdate (System.Single deltaTime) (at Library/PackageCache/se.hertzole.gold-player@eef1158b7d/Runtime/Core/Modules/PlayerCamera.cs:233)
Hertzole.GoldPlayer.GoldPlayerController.Update () (at Library/PackageCache/se.hertzole.gold-player@eef1158b7d/Runtime/Core/GoldPlayerController.cs:127)
"

This is almost definitely me doing something wrong and not realizing it but I don't know how I could have already done something wrong when I haven't really touched this package at all. Thank you for the support and sorry for the trouble!

Better jumping

Have a set amount of time where the player can press the jump button while in the air to jump again. This is because players often try to jump right before landing but it might fail and that makes it a frustrating experience.

Trying to use Gold Player with the old input system.

Using a standard setup on Linux Kubuntu by having the Gold Player Controller and Gold Player Input in the gameobject.
I don't have the new input system package installed, neither i have it enabled in the project settings.
I have 1 error which is:

KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <437ba245d8404784b9fbab9b439ac908>:0)
Hertzole.GoldPlayer.GoldPlayerInput.GetAxisRaw (System.String axisName) (at Assets/Hertzole/Gold Player/Scripts/Core/GoldPlayerInput.cs:127)
Hertzole.GoldPlayer.PlayerModule.GetAxisRaw (System.String axisName) (at Assets/Hertzole/Gold Player/Scripts/Core/Modules/PlayerModule.cs:130)
Hertzole.GoldPlayer.Core.PlayerMovement.GetInput () (at Assets/Hertzole/Gold Player/Scripts/Core/Modules/PlayerMovement.cs:400)
Hertzole.GoldPlayer.Core.PlayerMovement.OnUpdate (System.Single deltaTime) (at Assets/Hertzole/Gold Player/Scripts/Core/Modules/PlayerMovement.cs:439)
Hertzole.GoldPlayer.GoldPlayerController.Update () (at Assets/Hertzole/Gold Player/Scripts/Core/GoldPlayerController.cs:126)

In the GetAxisRaw I looked at what string is being used as the axis, it's "Player/Horizontal".

And Use Key Codes is true.

Version Info:
Unity: 2020.1.0a13.1443
Gold Player: 1.4

Head bob support

Add head bob support and make PlayerBob module work outside the player controller so it can be used for components.

Air control

Set how much you can control the player can move while in the air.

Camera shake

Add easy to use camera shake function in PlayerCamera.

How to disable "Can look around"?

What I want to do:
I want to do a pause menu. But, mouse look isnt lock.

What I've tried:
I'm write a script, where i tried:
using Hertzole.GoldPlayer; public class PauseMenu : MonoBehaviour { public GoldPlayerController Player; Player.Camera.CanLookAround = false; }
But, it's not worked.

upd: because i'm placed it in wrong public void, sorry

Provide examples

There need to be some solid example scenes to quickly check out the features.
In the Unity package version (.unitypackage) all of them will be provided on import.
In the package manager version, they should be provided as downloadable samples.

The examples should be just a test scene to play around in, interaction, animator, and UI.

Switching to using the new Input System Package

What I want to do:
Use the new Input System Package (ISP) instead of the legacy Input Manager

What I've tried:
Implemented my own features separately from the Gold Controller, so I'm aware of how the new ISP works with setting up user settings and adding bindings and whatnot.

Since your input system has an EnableAction(int buttonName) method, I tried to call that with an input binding:
image

The input I was attempting to use was Crouch, which I had bound in the ISP to both C and left-stick-click for controllers.

Figured out you're just using a hash of the button name, so I hardcoded the hash and the editor runs without errors when I click the stick, but I get no successful inputs.

Is there a way to actually trigger an input on the controller from outside the script? I don't mind jury-rigging method inputs by hand on an input-by-input basis, I just want to be consistent and not need to worry about having two different input systems.

Stamina for running

You should be able to set limited stamina for running and some extra settings related to that regarding regenerating it.

Head bob happens while player is not on ground

Bug description:
It appears that the head bob mechanic will run when the player is not touching the ground, as an example jumping off a ramp.

To reproduce:
Jump off a tall object and continue to hold W key while jumping, head bob animation should continue to play.

Expected behavior:
Head bob should stop and return to default position when player is falling.

Screenshots:
Head bob on
issuereport

Head bob off
issuereport2

Desktop and versions:

  • Your OS: Windows 11
  • Target OS: Windows, Linux (Dedicated server)
  • Unity version: 2022.3.14f1
  • Gold Player version: 1.7.1

Additional context:
None that I can think of right now.

Bug?

Hi, thanks for really good movement script. But i have two problems
When my player want to jump
he hits the roof?
and when im trying crouch he's under the world...
Could you help me? Thanks a lot!

Cannot jump when up against any kind of wall collider...

Hi again! I've found that whenever I use this player controller I always run into the same issue. Whenever I have the player walk up against any object and jump, the player tries to jump but is very quickly launched downwards before the full jump can even occur. This also happens when jumping towards a ledge that you do not have enough height to climb, it will simply launch you down to the ground. I have had this happen to me on numerous unity projects and I have never found the issue. I can import the base gold player controller into the game and this issue happens right out of the box without my making any changes and I was hoping for some help. Thank you very much and sorry for the trouble! I can provide videos if you like but I'm sure it is easily replicable on your system lol. I'm confused as to why this problem has never been reported though so I'm not sure what this could be...

Gold Player movement is buggy on low time scales

Bug description:
When the time scale is set to something low, like 0.1, movement becomes weird. For example, you can longer jump consistently.

To reproduce:

  1. Create a gold player controller.
  2. Set the time scale to 0.1.

Expected behavior:
Gold Player should function the same way as with a time scale of 1 but just slower.

Desktop and versions:

  • Your OS: Windows 10
  • Target OS: Editor
  • Unity version: Unity 2019.4.9f1
  • Gold Player version: 1.6

Player events

Add events for certain things, like jumping, landing, crouching, etc.

Allow for camera based recoil/external forces being applied to the camera rotation

Hi,
first off, thanks for creating such a cool player controller.
I keep coming back to it, ever since I found it some day ๐Ÿ˜„

Is your feature request related to a problem? Please describe.
I would like to be able to apply camera recoil to the player controller, while still respecting the Minimum X and Maximum X rotation of the camera.

Describe the solution you'd like
I would like to have a method like ApplyExternalRotation(float horizontal, float vertical) available to me on the PlayerCamera module. It should then add the two values to the internally tracked rotation of the Camera Head. This way we could modify the camera rotation by external forces, without having to sacrifice the limits emposed on the character.

For sure, there is a problem, when reaching the maximum rotation due to the external forces.
I think though this is fine.

Describe alternatives you've considered
I.e. adding a child to the Camera Head and applying the recoil there can be done, but leads to the min and max values being shifted by the applied recoil.

Additional context
Add any other context or screenshots about the feature request here.

Head bob does not work well together with mouse movement and crouching

The head bob feature does not work as expected when it's targeting the same transform as the camera module.
Example: PlayerCamera and PlayerBob both target "Camera Head". This stops the player from being able to look down and up and the player can no longer crouch.
Possible fix: Stop both PlayerBob and PlayerCamera from setting values and make them adapt around the current state of the transform... somehow.
For now, a workaround is to set PlayerCamera to target "Camera Head" transform and the PlayerBob to target "Player Camera" transform child.

Humanoid Rig

Why is the "Humanoid" a generic rig? I wanted to use this with UMA. I did work on it, kinda got it to work. It would have almost been a drop in if the animations were not generic. My feature request is an actual humanoid rig with humanoid animations.

Cannot jump

I downloaded the latest release and I cannot jump. I've tried enabling and disabling jumping and all the toggles.

How can I embed the code in my project so I can modify the code my self

Sorry if it is a very simple question, I just started using Unity and would like to use your project as my (third) person controller. I really liked many of the functions you have here and would like to adapt it to what I want. (have a many acceleration speeds or try to allow it to jump while running).

Would it be hard to give me some instructions on how to proceed?

Thanks,

Rigidbody support

Convert most of the code to work with rigidbody instead of character controller, or maybe alongside character controller.

This is because character controller has turned out to be really annoying when it comes to dealing with physics. This will require a big rewrite of a lot of code.

Replace box ground check

Box check was very poorly implemented and can easily be exploited to climb wall corners. Should be replaced by another system, most likely a group of raycasts.

Player audio

Add support for footsteps, both for walking, running, and crouching, landing and jumping.

Can't set position through script

When trying to set the player position through script using transform.position, it just doesn't work... sometimes. For unknown reasons, it sometimes works and sometimes doesn't.

Something in the PlayerMovement module is causing this behavior. Resetting moveDirection, movementInput and groundVelocity before setting the position does not help.

Error when on any Unity Version earlier than 2019.3, and not using the new Input System.

In the GoldPlayerTests class I get an error because the MovingPlatforms.Initialize() method always needs two parameters.

#if ENABLE_INPUT_SYSTEM && UNITY_2019_3_OR_NEWER
            playerController.Movement.MovingPlatforms.Initialize(playerController, input);
#else
            playerController.Movement.MovingPlatforms.Initialize(playerController);
#endif

This could be fixed by adding null to the Initialize Call or add a default value to PlayerModule.Initialize().

Having problems using the new input system with mouse input.

I'm trying to use the new unity input system, and it seems this project does support it, but without a Input Action setup example, it's a bit hard to know how to setup it.

I've figured out how to use the buttons, but I so far:

  • Created an action map called "Player"
  • Created a "Look" Action with the type being "Value" and control type "Vector 2"

The path that works best on the binding of the Look action is the "Delta [Mouse]", but I can only move the mouse when the mouse is not locked to the screen.

As a final note I haven't changed the default values in the Gold Player Controller.

Interaction

Hey, I'm trying to wrap my head around using the interaction part. The farthest I've gotten was making the interact prompt disappear. Please help.

Unsure how to properly setup.

Hi, I'm trying to get a simple capsule player set up to test out some ideas but I can't quite figure out how to get the gold player controller to work. I have the CameraHead and the TargetCamera set as the camera in the player's head, but I can't figure out how to get the HeadBob working. If I set the HeadBob to the capsule, it puts the camera at the correct height and the Bob works perfect, but I can't rotate the camera horizontally with the mouse. Any help would be appreciated. I love the UI for this and the features seem amazing. I really want to know how to use it properly to take full advantage of it.

Thank you!

Look angle animation not working

All other animations with the Gold Player Animator seem to work well.
I have a humanoid rig and I'm pretty sure I've done everything the exact same way as it's made in the example scene.
I tried with/without Avatar mask, different weights, different animations, different reference Head transforms and when viewing the head tilt inside the Head blend tree, the head tilting is working.

Box ground check

Right now the ground check is using a sphere at the bottom of the player.
There should be an option to switch between the sphere and a box. The box should not make the player slide down edges but instead fall once the player is fully in the air.

Sliding

This idea comes from the recent Call Of Duty movement system. Where the player, while running, hits the crouch button to slide; for a short period of time making the player faster while also losing said velocity over time; transitioning into a crouch when the player stops.

I made a mock-up edit to the code which simply makes the player move faster within a certain time frame and crouching when its over to demonstrate this better:

https://youtu.be/KRGrQy6wtqo

Keep in mind, that implementation is a simple timer script, and returns the player to normal crouch speed after the timer hits 0. It does not account for lost velocity over the time frame!!

To demonstrate the Call Of Duty movement system, what better way than to show you Call Of Duty :D

https://youtu.be/SyTmwtkjtcM?t=18

You can see as the player slides, they lose speed. I personally love this movement system. It makes the gameplay feel so diverse.

Thanks for your time,
erherhh4herh.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.