Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock system with text indicator #36

Merged
merged 7 commits into from
Sep 17, 2023
Merged

Lock system with text indicator #36

merged 7 commits into from
Sep 17, 2023

Conversation

TheFunnyBrain
Copy link
Contributor

To add feature/issue #33 (locks) I've implemented a system we use at my workplace.

Presently it's a simple implementation, and I've tried to keep things very minimal.

It's possible to extend this by adding multiple lock components for various things (physics update, camera controls etc), but I'd like to make sure this works as designed, and follows the principles of existing code before overdoing it.

It uses the GameAttribute system to display a brief message explaining that the user needs to press p to restore movement.

To stop the player running for eternity, I reset their movement in PlayerController.gd. This might not be best practice, and thought it was worth drawing attention to in case it's a terrible way to solve the problem! :)

	`direction = Vector3.ZERO
	character_component.add_movement_input()`

In terms of use cases, locks can be applied to practically any element of a game or character system

  • Movement (implemented in this pull request) - e.g. sitting in a seat, talking to an NPC, cutscenes
  • Camera control - force player to look at something, separated to allow player to look around independent of movement.
  • Locking physics updates - player freeze, game pause, etc
  • Game logic - anything that needs dynamic conditions to be added and removed e.g. level selection requirements, NPC dialogue options

@ywmaa ywmaa added this to the Version 1.0 milestone Sep 16, 2023
@ywmaa ywmaa added the enhancement New feature or request label Sep 16, 2023
@ywmaa ywmaa linked an issue Sep 16, 2023 that may be closed by this pull request
@ywmaa
Copy link
Owner

ywmaa commented Sep 16, 2023

1-

To stop the player running for eternity, I reset their movement in PlayerController.gd.

currently for this system, this is the right way!
I think I should add a function in the system later for one_time_stop() / movement_reset()

2- maybe add another signal :

signal Lock_Removed(lockName:String)

3- Using PausedAttribute.gd

in the first place I made GameAttribute for stuff like health and stamina, your use of it is quite interesting,
do you think that it is worth it to have Pause Variable as a Player Attribute ?
or having it as a variable var is_locked : bool in the LockSystem.gd will be enough ?

but also having it as a GameAttribute is quite inpsiring for Template users to use GameAttribute Creatively.
so I am not sure what we should go with, what is your opinion on it ?

@TheFunnyBrain
Copy link
Contributor Author

1-

To stop the player running for eternity, I reset their movement in PlayerController.gd.

currently for this system, this is the right way! I think I should add a function in the system later for one_time_stop() / movement_reset()

2- maybe add another signal :

signal Lock_Removed(lockName:String)

3- Using PausedAttribute.gd

in the first place I made GameAttribute for stuff like health and stamina, your use of it is quite interesting, do you think that it is worth it to have Pause Variable as a Player Attribute ? or having it as a variable var is_locked : bool in the LockSystem.gd will be enough ?

but also having it as a GameAttribute is quite inpsiring for Template users to use GameAttribute Creatively. so I am not sure what we should go with, what is your opinion on it ?

Thanks :) That's great to know :) I considered adding a function, but didn't want to go too far out of scope for a first commit! :)

2

Thank you, I've added the signal for removing locks in, that was an oversight on my part. :)

3

At work, we just use NavigationManager.IsLocked and InteractionManager.IsLocked, so I feel it could be simplified without any real headaches. :)

It could be nice to have some lock states as player attributes (e.g. to track player abilities, status effects), however it is very likely overkill, not to mention, a true pause would be a more global game-level variable.

I'll demote the UI to read is_locked, as that's plenty for just manipulating player navigation.

…the lock system - now uses the wonderful Signal system! :) Also repathed the project.godot icon to prevent an error, and added a few debug functions to LockSystem
@TheFunnyBrain
Copy link
Contributor Author

3 - Using PausedAttribute.gd

One better, I'm using signals, as they are wonderful and much easier than making a node just to enable the label object! :)

@ywmaa
Copy link
Owner

ywmaa commented Sep 17, 2023

Looks good, thanks for the very nice system.
Also Thanks for fixing the Typos (References, mouse_sensitivity)

@ywmaa ywmaa merged commit ab13a8e into ywmaa:master Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lock system
2 participants