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

Add slope support #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maystey
Copy link

@maystey maystey commented Apr 5, 2020

The character used to slide down slopes with a low enough incline to be
the floor (this is now fixed).

The character used to run up (or slide up if in the Air state) slopes
that are too steep to be the floor (this is now fixed).

New bad behavior:

  • On slopes with an incline equal to max_floor_angle, the character
    makes a slight hop after running up and looses their grounding when
    running down them.
  • When the character runs into a steep slope they perform short hops due
    to sliding upwards. Ideally the player would stay on the ground (no
    sliding up the slope). This can be exploited to jump higher.

A new ramp obstacle (Rampy) was added to the main Game scene to test the
slope behavior.

Closes: #25

Please check if the PR fulfills these requirements:

  • The commit message follows our guidelines.
  • For bug fixes and features:
    • You tested the changes.
    • You updated the docs or changelog.

The character used to slide down slopes with a low enough incline to be
the floor.

The character used to run up (or slide up if in the Air state) slopes
that are too steep to be the floor.

New bad behaviour:
- On slopes with an incline equal to max_floor_angle, the character
makes a slight hop after running up and looses their grounding when
running down them.
- When the character runs into a steep slope they perform short hops due
to sliding upwards. Ideally the player would stay on the ground (no
sliding up the slope). This can be exploited to jump higher.

A new ramp obstical (Rampy) was added to the main Game scene to test the
slope behaviour.

Closes: gdquest-demos#25
@NathanLovato NathanLovato changed the title Fix unwanted character sliding on slopes and add new ramp obstacle Add slope support Apr 5, 2020
Copy link
Collaborator

@NathanLovato NathanLovato left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution. I wouldn't merge the code with the current bugs that come with the feature. There are also some other changes required, see the review comments.

Note this isn't a fix, but a new feature. The current stable version of Mannequiny not supporting slopes is intended. As you can see, smooth and bug-free slope support is not that easy to add.

[node name="Playground" parent="." instance=ExtResource( 5 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 0, -16 )

[node name="Rampy" parent="." instance=ExtResource( 9 )]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you name it something like Ramp or TestRamp ? The names should make sense in the project. Mannequiny is a particular case as it's the name of the character

Copy link
Author

Choose a reason for hiding this comment

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

I was trying my luck here, will do.

_parent.enter()


func exit() -> void:
_parent.snap = Vector3.DOWN
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would rather override the _parent.physics_process(delta) call in physics_process and use move_and_slide in the Air state than mutate that snap vector in different places. At least, instead of this value, we should use a constant in the Move class, so there's only one place to change the default snap vector length. 1m is pretty long and I've had the character go down abruptly on the ground due to the current value.

Copy link
Author

Choose a reason for hiding this comment

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

The problem is the parent class has more logic in the physics_process related to inputs and rotating the character.

Perhaps if I make a constant as you suggested and make a public method to change the snap direction? There could also be a default snap direction (down) if no argument is given.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure what's best. I was thinking of something like that to start with:

It was in that sense.

# Move.gd
const SNAP_DEFAULT := Vector2.DOWN

...

# Air.gd
func enter(...):
    _parent.snap = _parent.SNAP_DEFAULT

It's just a matter of not duplicating the values, as that's a guaranteed source of silent bugs in my experience.

And I'd rather have us stick to properties, as it's more in line with the rest of Godot 3.0+

@@ -8,7 +8,7 @@ func unhandled_input(event: InputEvent) -> void:

func physics_process(delta: float) -> void:
_parent.physics_process(delta)
if player.is_on_floor() or player.is_on_wall():
if player.is_on_floor() :
Copy link
Collaborator

Choose a reason for hiding this comment

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

Space left before the :. You can use a code formatter to address these things for you: https://github.com/Scony/godot-gdscript-toolkit/

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, I'll check it out.

@@ -3,21 +3,27 @@ extends PlayerState


func physics_process(delta: float) -> void:
var velocity_previous_y = _parent.velocity.y
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use type hints. Here, you can use type inference var velocity_previous_y := _parent.velocity.y

If I get it correctly, the changes here prevent the player from sliding up steep slopes in the Air state? If so, this is not the way to handle this. When walking against a slope that's too steep, the player should not enter the Air state in the first place.

Copy link
Author

Choose a reason for hiding this comment

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

I was being a bit lazy, inference wasn't working in this case. I'll fix it.

@maystey
Copy link
Author

maystey commented Apr 5, 2020

@NathanLovato Thank you very much for your feedback on all of this.

I have a technical question related to pushing further commits. The guidelines state that the commits should be squashed. Should I push further commits to this branch and squash it later, or should I squash it each time before pushing and force it?

@NathanLovato
Copy link
Collaborator

I have a technical question related to pushing further commits. The guidelines state that the commits should be squashed. Should I push further commits to this branch and squash it later, or should I squash it each time before pushing and force it?

As you prefer, I can also use the squash and merge feature from GitHub at the end so you don't have to rebase yourself. We have this for the team, as we generate lots of commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slope Support
2 participants