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 #33

Closed
TheFunnyBrain opened this issue Sep 15, 2023 · 12 comments · Fixed by #36
Closed

Lock system #33

TheFunnyBrain opened this issue Sep 15, 2023 · 12 comments · Fixed by #36
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@TheFunnyBrain
Copy link
Contributor

For the company I work for, we make use of a lock system, to restrict player movement whilst using UI, or in a cutscene.

The way we found best, is a privately settable Dictionary of strings.

Locks.AddLock("TalkingToCompanionA")

Locks.RemoveLock("TalkingToCompanionA")

Input can then check locks.count/locks.length etc with a property or method, e.g.

if(!Locks.IsLocked)
{
    //accept input
}
  • The strings are set by developers, and help with debugging as we can print out what's going on.

  • The collection is important, as it means multiple things can manipulate the locks without unlocking things unintentionally

  • e.g. A player is on a pause menu, fast travels, then return to the pause menu without the fast travel's locks interfering with the pause menu still needing the player to be immobile after the animation.

This one is something I'd be happy to work on, but only if it's useful. :)

@ywmaa

This comment was marked as off-topic.

@ywmaa ywmaa added enhancement New feature or request good first issue Good for newcomers labels Sep 16, 2023
@ywmaa ywmaa added this to the Version 1.0 milestone Sep 16, 2023
@ywmaa

This comment was marked as off-topic.

@ywmaa

This comment was marked as off-topic.

@ywmaa

This comment was marked as off-topic.

@ywmaa
Copy link
Owner

ywmaa commented Sep 16, 2023

@TheFunnyBrain

Lol, I JUST REALIZED I UNDERSTOOD Lock system wrong, resulting me working on another features, LOL.

but now I understand your game LOCK System.

still it will help.

in my game the lock system was using one Variable called in_game, your idea is much better.

Please add this system, as it will help a lot of games that will use this Template, plus, it may help turn this Template into a whole Demo, because it will make Menus work flawlessly with this template.

@ywmaa
Copy link
Owner

ywmaa commented Sep 16, 2023

@TheFunnyBrain

I made this PlayerController Script :
c3ef313#diff-2642a77dfb50662044ce692d38d2067a604e56aafbe6372b1dce31a50d6c576f

So you can add the system you meant here.

@TheFunnyBrain
Copy link
Contributor Author

Awesome! :) Thank you :)

I have added the feature to PlayerGamePlayComponent in a local branch, but it's no trouble to throw it over :)

I'm just trying to work out how best to get the locks connected to the player, but as an optional component. Initially it's as a preloaded .gd script, so I'm going to try and turn it into a proper node that can be there or not. :)

It's strange migrating from Unity, where I'd do something like a null check or even trygetcomponent at launch. :) That said, I am really getting a kick out of the friendliness of GDScripts - is so simple with handling things like dictionaries!

I am also looking to try and make it support signals, so that we could for example have debug UI.

@TheFunnyBrain
Copy link
Contributor Author

I've rewritten it in nodes, added a nullcheck etc, so hopefully it'll do the trick. :)

Would I be okay to add a pause key (e.g. the 'p' key) to test the system works? :) It's doing absolutely nothing presently, which is exactly as intended - so I guess the next test is to add a lock, see what happens.

@ywmaa
Copy link
Owner

ywmaa commented Sep 16, 2023

Would I be okay to add a pause key (e.g. the 'p' key) to test the system works?

Yes, no problem, actually you should consider adding a way so the users of the template know that this feature exists.

for me the Pause Key "p" is good enough, and I may add a simple Pause screen for it in the future.

@TheFunnyBrain
Copy link
Contributor Author

That sounds perfect! :) I've added the 'p' key in for now, and hopefully I can add a small UI element to tell the user what's happening. :)

I did notice an amusing side effect of my implementation - the player walks, or runs indefinitely whilst locked! I'll resolve that now, I think it might be that I need to switch the character to an idle state. :)

I'm guessing physics might also be a consideration, but I won't get ahead of myself for now. Quite frankly, I'm astonished any of my GDScript is working on day 2, it is a nice feeling.

@ywmaa
Copy link
Owner

ywmaa commented Sep 16, 2023

I saw your scripts, and you are a good user of GD script.

Keep going 👍

@TheFunnyBrain
Copy link
Contributor Author

Thank you :) That's really encouraging to hear, it's a nice jump, and I'm having fun. I have a perpetual fear of wading into someone's project, and busting things through lack of knowledge.

I've made a pull request now, and I can fix any issues, add anything, change things etc. :)

@ywmaa ywmaa linked a pull request Sep 16, 2023 that will close this issue
@ywmaa ywmaa closed this as completed in #36 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 good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants