Godot Version
v4.2.2.stable.officiel [15073afe3]
Question
So lately i’ve been trying to get really into Godot and actually make a project that I want to finish. So far it is going smooth and im creating my own assets etc.
The problem is however, that I keep ‘stuttering’ my way through my gridmap floor whenever i run my scene, and thus fall into oblivion. So it does detect some form of collision, but not correctly.
Here is some context:
I didnt have this problem beforehand! My gridmap collision was working somewhat correctly previously, however i kept ‘teleporting’ small distances from time to time, when navigating my scene with my player character. I found some people talking about using 2d planes in a 3d scene being a possible cause for weird collisions, so i tried remodelling my assets to have floors that had a thickness. This was what caused my issue and i started stuttering through the floor. I have attempted to revert to my old assets, and now I’m just fully falling through my floor (with far few stutters from collision) .
I also used blender for creating my assets. These are all simple, low poly assets that make up tiles for a gridmap. I originally exported these with the suffix ‘-col’ to autogenerate collision. I have since tried manually creating collision meshes in godot to see if this would fix anything.
I am somewhat lost as to what might be the problem and I’ve tried looking around the forums for people encountering similar issues. I hope someone could maybe spot whatever is going on and point me in the right direction
Code for player movement:
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = jump_velocity
# Get the input direction and handle the movement/deceleration.
var input_dir = Input.get_vector("left", "right", "forward", "back")
var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
move_and_slide()
#Handle player movement animation
if velocity != Vector3() and is_on_floor():
head_bob_animation.play("head_bob")