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

CharacterBody3D snap, from Vector3 to Float #60075

Closed
Whimfoome opened this issue Apr 9, 2022 · 1 comment
Closed

CharacterBody3D snap, from Vector3 to Float #60075

Whimfoome opened this issue Apr 9, 2022 · 1 comment

Comments

@Whimfoome
Copy link

Whimfoome commented Apr 9, 2022

Godot version

4.0.alpha6

System information

Windows 10

Issue description

I began rewriting my First Person Starter in Godot 4.

I noticed that the Snap Vector is now a Snap Length (Vector3 -> Float), and in my understanding form the docs, it's in the opposite direction of the up_direction. Here is my problem:

2022-04-09_20-51-28.mp4

In Godot 3.x i did something like

if is_on_floor():
		snap_vector = -get_floor_normal() - get_floor_velocity() * delta

In Godot 4 there is no way to do this, because it's somehow handled behind the scenes and these are all the properties
image
and if I refer to some of the docs (I don't know if they are up-to-date), this snap_length is the opposite direction of up_direction, but if I mess with it like this:

if is_on_floor():
		up_direction = get_floor_normal()

my controller doesn't snap to the floor when the floor normal changes and I "rocket" myself into the air

2022-04-09_20-59-22.mp4

Is there any official demo or example to see how it should be handled or somebody who knows about physics in Godot to tell me what am I doing wrong.

Steps to reproduce

  1. Download First Person Starter from the godot4 branch
  2. Try going up and down on slopes and you lose contact with them
  3. Try with the Godot 3 branch

In the Godot 3 version, the logic is in the res://Player/Player.gd path.
In the Godot 4 version, the logic is in the res://Player/MovementController.gd path

Minimal reproduction project

godot-FirstPersonStarter-godot4.zip

or

https://github.com/Whimfoome/godot-FirstPersonStarter/tree/godot4

@Whimfoome
Copy link
Author

Don't know what I was doing at the time of writing this issue but I tested it with alpha 7 and the issues described are not present. I was like oh cool, decided to try with alpha 6 just for fun and it worked there too, so no idea what I was doing.

Now I just set the snap_length to 0.5 and constant_speed to true (optional) and now it's working. I'm pretty sure I tried the same thing last time before going deep into some custom solution...

And for people who want more control over the floor angle handling and such there are nice methods such as get_floor_normal() and get_floor_angle() and many more!

@akien-mga akien-mga removed this from the 4.0 milestone Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants