Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Cameron Kilgore |
I am in the process of updating a v2 project to v3 to help assist developers in developing their own 3D projects. While some components I have ported over work without failure, I am encountering some event-driven issues, namely with player movement. This extends from the project in question.
In the code example below (taken from the project’s player.gd script), I have a player pawn that is granted free movement, and the ability to jump. However, when I do jump (while holding down a movement key) and land (throwing is_on_floor()), the player can’t move in any direction. Once I lift all pressed keys, I can resume moving.
The code that handles jumping and motion is posted below:
if motion != null: #TODO length() function doesn't exist here, find replacement (not null check working for now)
while is_on_floor() && attempts: #TODO Invalid Call nonexistent function is_colliding in base 'KinematicBody'
var n = get_collision_normal();
if (rad2deg(acos(n.dot(Vector3(0,1,0))))< MAX_SLOPE_ANGLE):
on_floor = true;
motion=n.slide(motion);
velocity=n.slide(velocity);
if original_vel.dot(velocity) > 0:
motion=move_and_collide(motion);
if motion.length() < 0.001:
break;
attempts-=1;
if on_floor and Input.is_key_pressed(KEY_SPACE):
velocity.y = jump_speed*gravity_factor;
on_floor = false;
I’m not really sure what the cause could be. In discussions on Discord, it was some form of bug that emerged with v3. Any insight on how to address this bug would be helpful. Thanks again.