My Godot version is 4.3
The move_and_slide function is causing slight sliding when I run it. I know it’s the move_and_slide function after doing some debugging, because it only begins to change the positioning after the move_and_slide function runs.
It only changes the positioning of the player on the X and Z axes, and it only changes by a very minimal amount. To the point where the only way to tell it’s moving is through the use of print() statements or looking really closely at the pixels, but I could feel that something was off before I even realized the problem. So it isn’t a massive deal, but it makes the game feel janky and unfinished (which it is, but I’d like to solve this issue now rather than later.)
This is the part of the code in which I suspect it’s occurring. As my game is in the very early prototyping stages, this is the only script there is.
I should mention that what I am trying to do is create a camera system similar to that of Ocarina of Time.
Please help me, oh people who are smarter than me
KingGD
January 31, 2025, 1:57pm
2
Why are you multiplying the delta with that velotttity
, you did not need to do this, you can normally write that.
1 Like
Oh, I thought I had to use the delta to make it sync up with different screen frequencies… what’s the point of the delta in that case?
1 Like
wchc
January 31, 2025, 10:46pm
4
In most cases multiplying by delta for movement calculations makes sense, but move_and_slide()
method is kinda an exception, because internally it uses the delta already, so there’s no need to multiply the velocity by delta yourself.
There is this proposal to externalize this calculation, so maybe in the future this will change.
opened 07:35AM - 03 May 24 UTC
topic:physics
breaks compat
### Describe the project you are working on
A multiplayer 3D RTS game that us… es differing tick rates for different objects
This issue was already raised here https://github.com/godotengine/godot-proposals/issues/1192, but much of the discussion is about Godot 3's `move_and_slide` which allowed passing of velocity as a parameter. In contrast, Godot 4's `move_and_slide` does not accept any parameters, which causes this issue.
### Describe the problem or limitation you are having in your project
[Minimal reproduction project](https://github.com/deltasiege/godot-move_and_slide-issue)
It is impossible to use `move_and_slide` in a deterministic way because [it multiplies by frame delta internally](https://github.com/godotengine/godot/blob/06d105e268ace265809ae3fac2f17ccea9ff88dd/scene/3d/physics/character_body_3d.cpp#L37) - which forces floating point math to be used
In contrast, modifying a Node's position manually or using `move_and_collide` can be done without any floating point math because frame delta is not considered
Imagine a project with this setup:
1. Physics frame rate via project settings set to 60 FPS
2. Our most important objects `move_and_slide` on every physics frame as normal - no issues
3. We have other less important objects that we would like to `move_and_slide` every 10th physics frame
4. We implement a system that cumulates pending physics frames in order to multiply their count against the `move_and_slide` velocity
5. Since `move_and_slide` multiplies the character's velocity internally, small floating point errors will be introduced between the important and unimportant objects - which will eventually manifest as desynced positions
### Describe the feature / enhancement and how it helps to overcome the problem or limitation
Remove frame delta calculations from `move_and_slide`:
- removing [this line](https://github.com/godotengine/godot/blob/06d105e268ace265809ae3fac2f17ccea9ff88dd/scene/3d/physics/character_body_3d.cpp#L38) from `move_and_slide`
- removing any mentions of delta in that same function
- have that function accept a velocity parameter in the same way that `move_and_collide` does
### Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
1. Remove delta from `move_and_slide` as described above
2. Document expected usage of `move_and_slide` as follows:
```gdscript
extends CharacterBody3D
var speed = 1
func _physics_process(delta):
velocity.x = speed
move_and_slide(velocity * delta)
```
### If this enhancement will not be used often, can it be worked around with a few lines of script?
No
### Is there a reason why this should be core and not an add-on in the asset library?
`move_and_slide` is a core engine function
### Related
- https://github.com/godotengine/godot-proposals/issues/1192
- https://github.com/godotengine/godot/pull/84665
- https://github.com/godotengine/godot-proposals/issues/2821
Ohhhh really? That’s actually really interesting, thank you! I’ll see if removing delta helps
Update: It seems to have slowed down the movement even further, but it’s still on the move