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

Cogito Sittable #265

Merged
merged 60 commits into from
Oct 1, 2024
Merged

Cogito Sittable #265

merged 60 commits into from
Oct 1, 2024

Conversation

niefia
Copy link
Collaborator

@niefia niefia commented Sep 10, 2024

Addition of the Cogito Sittable as proposed here #255

Still WIP with the following issues needing to be handled before implementation:

  • Look marker defining player horizontal sitting vision
  • Sittable interaction behaviour on non standard player states; crouching, jumping, on ladders etc
  • Controller support
  • Sittable area Player detection moved back from process to signal

Basic implementation of the Sittable Class & Player handling of sitting
First iteration and very buggy but has the basic functionality required of the Sittable
Also included a icon for the Class
Disables Carryable component if found, currently checks for this at the sibling level.
This option is to avoid some issues with Sittable components on physics bodies, so is set to on by default
Fixed clipping through Floor on stand up bug by disabling physics during stand up tween
Added Look angle, added (currently unused) signalling
Added node & variables for look marker to define centre of vision, but couldn't get this working yet
…ignals

Refactored everything so that the Sittable does not move player, only signals to player.
Added displacement height to Sittable marker

Bugs: Switching from 1 seat to another no longer works
Interacting with Sittable while crouched causes player to be too low
…sics update

Fixed - Moving between Seat.
Added Sit audio, and Player location physics update
Bugs - interaction text incorrect on moving between seats
Fixed label issue on move by telling the previous seat node to "stand_up" when moving seat
Added Sit area for Sittables, the interaction only shows when the player is in the sit area

Couldn't get reliable behaviour for sit area using the signals directly so moved logic to physics process until I can fix that
@niefia
Copy link
Collaborator Author

niefia commented Sep 10, 2024

@ac-arcana Continuing from the discussion in #255, I've tested the ladder interaction and doesn't seem to have any weirdness like that currently since on sitting, physics is disabled and the player just tweens to the sitting marker location.

If you actively wanted to replicate that bug effect you'd probably have to do the movement through physics instead.
Is this a common enough thing to introduce an alternate sit mode?

Crouch handling + better sizes defaults Sittables
Player horizontal vision now restricted based upon Sittable settings and look marker

This solution works mostly with 2 issues that need to be solved still:
Player need to be looking at the Look marker at end of the sitting tween, so that player does not begin stuck sitting looking inside a invalid look region.

If mouse movement is fast enough player can skip over the invalid look region. so from max left look to max right look
Tween to look marker added, which is needed so player faces the look marker on sitting down. So player is always facing within the look area now

Player has to restore original neck rotation on stand up due to issues with neck remaining twisted on physics seats that are weird angles
@niefia
Copy link
Collaborator Author

niefia commented Sep 11, 2024

Wanted to test some weird uses so made a Swing by just attaching a desk chair to hinge node and here's the results:

cogito-swing.mp4

Don't think its too bad given I hadn't even consider this case at all, but I can see what needs changing to work better

Basically just need a dynamic tween if its a physics object in case it moves mid tween, also the vertical look parameters need to be defined by the Sittables axes.

For performance reasons it might also be worth having a Static or Physics option for Sittables so that Static ones skip all the extra things required for Physics sittables.

Separated Static and Physics Sittables, to avoid using unnecessary resources on static
Sittable area detection was previously done in physics process (due to weird issues with signals not working properly before).
Now it's done by signals, so should improve performance as every sittable won't be checking its interactability every frame.
Tween duration wasn't fully applied before and Rotation tween duration  has been added as a new export var to Sittable to control this
Vertical look handling must be separated for Sittables as Physics sittables vertical view will change on move, implemented handling solution is temporary
Added Vehicle class that inherits from Sittable, It's very basic and not looking to expand upon this much just included for demo purposes of Sittable uses.
The office chair has been made into a vehicle
Sit area behaviour modes now define what the Sit area does, the modes are:

MANUAL,  ## Player needs to interact manually - Previously the only mode
AUTO,    ## Player sits automatically on entry - Could be useful for suggested use as a trap
NONE     ## Player can interact from outside Sit Area

Reorganised the export vars
Also added enable_on_sit, which can be used for enabling player sitting collision shapes or any other node
Sat on start places player on Sittable on ready,

Call interact is currently just copied from switch, considering instead refactoring Switch into a more general class that both could inherit from to avoid this, this would also allow area activation to be used as switch trigger, meaning area activated switches.
@Phazorknight
Copy link
Owner

Finally had a chance to check this out, and gotta say: this is pretty amazing!

Everything works as I'd expect this to be and the setup of the object is very much in line with the Cogito style.
Was surprised that I could even slide from one seat to the next at the couch in the cafeteria.

The vehicle is pretty cool as well as an early proof-of-concept. If we develop this one further, it would need an "exit position node" as currently, when I stand up from it after "driving around", I slide back to the position I was in when I first got into the vehicle.

@Phazorknight Phazorknight added the enhancement New feature or request label Sep 12, 2024
Added bear trap to demonstrate further uses of Sittable class,
Added node hide/show, same as Switch
Also added some (not yet functional) variables as more Sittable options
@niefia
Copy link
Collaborator Author

niefia commented Sep 12, 2024

Thanks for the feedback, the seat to seat movement was an early consideration as the sofas being wide enough for 2 Sittables made me think it was needed.

Working on implementing different options for the on leave behaviour, with the following types:

ORIGINAL,  ## Player returns to original location - Current Method
AUTO,    ## Player sent to random nearby available location 
NODE     ## Player is placed at defined Leave node

Also saw the discussion on renaming the Sittable to something more broad, but don't want to change it until a consensus is reached on what to call that really.

My thought on name is that CogitoSittable is probably fine for it since it covers most uses and we'll aim to demonstrate the less usual ones for that. If we're ok with a Lift belonging to the CogitoDoor class, instead of something more generic like "Mover" then I think we should just keep the Sittable name.

I think Sittable is also more immediately understandable than something like PlayerRestrainer, despite it being less accurate, it is more approachable

Added multiple options for Sittable leave behaviour

Auto placement not yet implemented
@Phazorknight
Copy link
Owner

@niefia re naming: I see your points and agree. Let's keep the naming Sittable

In regards to "leave behavior": I might rename the Node option to something like Transform ? Unless there's other requirements needed/used, but Transform makes it clear as to what is being referenced.

How would the Auto behavior work?

@niefia
Copy link
Collaborator Author

niefia commented Sep 23, 2024

Sittables are now working with the save system as intended without compromising on functionality.

Just need to finish some things up and run some more tests, so probably going to be a bit until its finally merged

Rotation on load was being broken by parent node rotation, fixed by accounting for this.
Added is_fallen function, called by when interacted with.
Checks if the chair has fallen beyond eject_angle

Entering Fallen chairs causes lots of issues so best to just prevent it entirely.
While technically possible the swing would require a lot of custom unique features to implement, and have lots of swing specific issues.
Therefore decided to remove it for now, as Sittables already add a great deal of functionality. Swing would only be bloat
Added Sittables to every seat on the Lobby map

Added player feedback hints when interact cancels
Separate global, and local position in save data to fix bug with loading positions
Check if sitting before saving current Sittable, to fix bug on save
Vehicle had issues with the clamping around look marker
Remove look angle restriction on chair_desk to avoid this

handle_sitting_look will need future rewrite for vehicles, controller support & improvements
Prevent save on tween by disallowing pause menu during tween,

Avoids having to deal with save/loading player coordinates mid tween which can cause weird behaviour like player clipping through the floor, as collisions are disabled during tween to allow for smooth transition.
@niefia
Copy link
Collaborator Author

niefia commented Sep 24, 2024

Fixed up all the bugs that I'm aware of, and added a whole bunch of features to improve the stability of things.

Would be great if somebody else is able to properly test it out before Merge, as I wouldn't want to merge such a large PR without further tests.

@Phazorknight
Copy link
Owner

Gave it a quick look and run into two thing:

  1. Added the Swing to the Laboratory demo scene and noticed it didn't work right out of the box. Needed to activate "physics sittable" to it. As this is it's own packed scene, I assume it's fine to keep that.

  2. I saved my game while sitting on the swing. Then got up and attempted to load that save.
    Errored out with:
    Invalid set index 'sleeping' (on base: 'StaticBody3D (CogitoSittable)') with value of type 'bool'.
    from CogitoSceneManager at function load_scene_state line 302: node_to_set.sleeping = true

Reintroduced the Swing with proper implementation
Save the player node transforms for key nodes - Body/Neck/Head/Eyes/Camera to improve stability of save system. This is needed for swing
Replaced limit_vertical_view with vertical_look_angle

Edited the comments for clarity
@niefia
Copy link
Collaborator Author

niefia commented Sep 25, 2024

So I had removed the Swing, since it had a lot of unique issues that would only ever be present for a Swing. Intended to remove it entirely but hadn't got round to it.

However have had another try and managed to get most things working for it. Even the things I thought wouldn't.
Can't guarantee its 100% perfect though

@Phazorknight
Copy link
Owner

Did some tests and ran into a few issues that were a bit hard to reproduce (mostly on level scene changes, one time I had all rigidbody sittables double spawn in the lobby, but couldn't reproduce, might've been a scene state file issue).

One bigger issue, was able to get myself "trapped" in a sittable, here are the steps:

  • Start Lobby scene.
  • Sit down at the first blue chair on the left, facing entrance.
  • Save game.
  • Get up and start walking/sprinting towards conference room/archive room.
  • Load game.
  • Player is seated in blue chair but faces towards the conference room and is thus unable to aim at the "Stand up" interaction, staying trapped.
  • Also noticed that if I was sprinting when I loaded, my stamina kept going down. This could've been related with the cogito_player.gd issues introduced with Player exits crouching when opening Inventory or interaction GUI #283 though.

One suggestion in regards to saving and loading on a sittable: I'd probably just "eject" the player to the "leave" node (or general leave position depending on the placement on leave selection. That might be easier to implement.

I've been playing a bit of Abiotic Factor that also has placeable and movable objects the player can ist on and AFAIK that game doesn't save/load the player's seated state.

Save the Interactable state to avoid player being unable to interact, thus stuck in seat
Fixed angle on load
Also added backup collision shape when sitting to avoid instances where player does somehow still get stuck despite all above.
@niefia
Copy link
Collaborator Author

niefia commented Sep 26, 2024

Not able to replicate the first issue, so can't really comment on that one. If we can get it happening again will investigate further.

For the other issues I was able to solve them all, so looking pretty good to merge now unless you can find any more bugs.

Oh and the sprinting issue is definitely one introduced in #283 since I've encountered it on other branches. And think I first noticed it with the fix I did after that Commit.

Should be fine to keep save/load chair state, since it seems to work fine now.
I think I probably got the idea of Office chair vehicles from Abiotic Factor funnily enough.

@niefia
Copy link
Collaborator Author

niefia commented Sep 26, 2024

Just checked now and yeah quite a few issues with sprinting were introduced with the Trying to stop player from standing up while opening a GUI commit. All seems fine again if you revert back

@Phazorknight
Copy link
Owner

Wow, this is getting really robust. Great work!
Saving and loading all seemed to work.

Ran into two issues:

  1. The swing still seems to have a Carriable component. Was able to "break" it by starting to carry it, and suddenty the swing froze in place and I couldn't interact with it anymore either (neither carrying nor sitting. I assume removing the Carryable component will fix this.

  2. When saving while on the swing, then loading again, the mouse look seems to be limited to only up/down. Once I get up and sit down again, the mouse look seems to work again with left/right as well. I'd say this is very very minor.

Seriously fantastic work on this! Thank you again!

Removed Swing Carryable component
Added Sound to Sittables that were missing Sounds
Added Sittable to a seat that was missing one
Cleaned up comments + Statically typed some variables
@niefia
Copy link
Collaborator Author

niefia commented Sep 29, 2024

Removed the Swings carriable component and fixed up a few other things

Can't seem to replicate the second issue now, but think I may have encountered it previously. If it happens you can usually regain look by moving mouse side to side rapidly.

@Phazorknight
Copy link
Owner

Can't seem to replicate the second issue now, but think I may have encountered it previously. If it happens you can usually regain look by moving mouse side to side rapidly.

Yeah, trying this repeatedly now and it seems to happen only at specific moments while swinging in the swing, so it might be tied to the physics tics and/or the player controller in general. Anyway, like I said, not a big issue and overall this works really well now.

I'm up to merge this into main if you say it's ready.

@niefia
Copy link
Collaborator Author

niefia commented Sep 29, 2024

It's ready to merge, It's had a week of bug testing and fixes, and plays very stable.

Thanks for the help with bug testing

Copy link
Owner

@Phazorknight Phazorknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to merge!
Again, thank you so much for this.

@Phazorknight Phazorknight merged commit b8bf62b into Phazorknight:main Oct 1, 2024
1 check passed
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.

2 participants