![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | KramchayDig |
I discovered a problem when I’m standing between on an edge and a wall the gravity increments and I get stuck in there movement controls becomes stiff by the force of the gravity still falling. I waited for the gravity to increment and later destroy the cube. I printed the velocity output on run time.
I made 2 code for the player controls and the obstacle a code to destroy to see the player would fall hard by the immense gravity values still increment.
Code for the Player:
extends KinematicBody
var velocity = Vector3(0,0,0)
export var SPEED : float = 8
const UP = Vector3(0,1,0)
func _physics_process(delta):
var g = Vector3(0,-39.8,0)
velocity += g * delta
if Input.is_action_pressed("right") and Input.is_action_pressed("left"):
velocity.x = 0
elif Input.is_action_pressed("right"):
velocity.x = SPEED
elif Input.is_action_pressed("left"):
velocity.x = -SPEED
else:
velocity.x = lerp(velocity.x,0,.75)
if Input.is_action_pressed("forward") and Input.is_action_pressed("backward"):
velocity.z = 0
elif Input.is_action_pressed("backward"):
velocity.z = SPEED
elif Input.is_action_pressed("forward"):
velocity.z = -SPEED
else:
velocity.z = lerp(velocity.z,0,.75)
if is_on_floor():
if Input.is_action_pressed("jump"):
velocity.y = 18
pass
pass
velocity = move_and_slide(velocity, UP)
print(velocity)
pass
Code for the Obstacle cube:
extends StaticBody
func _process(delta):
if(Input.is_action_just_pressed("ui_up")):
queue_free()
pass
pass
hope to find answers for this problem it could be simple.