![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Vespiria |
This is on Godot 4.0.2 latest, and this is a fairly small prototype I made just for testing multiplayer using steam matchmaking + enet.
To start, here is my script for movement :
func _physics_process(delta):
if not is_multiplayer_authority(): return
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir = Input.get_vector("left", "right", "forward", "back")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
_speed = SPEED
direction = direction.rotated(Vector3.UP, spring_arm_pivot.rotation.y)
if direction:
if Input.is_action_pressed("run"):
_speed = RUNSPEED
velocity.x = lerp(velocity.x, direction.x * _speed, LERP_VAL)
velocity.z = lerp(velocity.z, direction.z * _speed, LERP_VAL)
armature.rotation.y = lerp_angle(armature.rotation.y, atan2(-velocity.x, -velocity.z), LERP_VAL)
_movement.rpc(true)
else:
velocity.x = lerp(velocity.x, 0.0, LERP_VAL)
velocity.z = lerp(velocity.z, 0.0, LERP_VAL)
_movement.rpc(false)
move_and_slide()
_movement() is just setting the animation tree to idle/walk/run values based on the currently velocity.length() / _speed for interpolating movement animations.
I’m not sure if the problem is my code or the created Trimesh Static Body that was generated by certain mesh’s. The mesh’s are parts of a decent sized map which is meant to be the prototype for testing. It is only made up of planes (maybe that’s an issue?) and I used careful precise measuring in blender to make sure everything lines up exactly.
Here is the main area I’ve found I’m getting stuck :
The red circles are all areas where the character seems to just fall right through and become unable to move/unable to stop the walking animation. Looking at the static body that was generated, it seems fine, I’ve even tried putting collision boxes in those spots to see if it helps but it does nothing, which makes me think it’s the code.
Here’s what it looks like when I get stuck :
https://streamable.com/frqs8z
Also my characterbody3d settings I have tried quite a few different settings and they haven’t really changed much besides make things worst.
Edit: Temporarily seemed to fix it by completely taking the generated trimesh out and just manually putting together my own with boxes. I really want to know what happened though so I can avoid this happening in the future.
Edit2: I went back into blender and added a solidify modifier to all of the floors/walls by just 0.1 and it seems to have fixed the issues I was having. It kind of sucks because it means I’m adding a bit more load but at least it works.
Having the same issue. My meshes are used as cells in a GridMap and often when going from a flat surface to a slope (or vice versa) my character gets stuck and I need to jump.
https://i.imgur.com/9BIgAq5.mp4
jer | 2023-06-27 17:07