Godot Version
4.3 stable
Question
its not codling with the bounding box
heres the code
extends CharacterBody2D
var SPEED = 30
#more is less
var friction := 0.015
func _physics_process(delta: float) -> void:
if Input.is_action_just_released('r'):
position = Vector2(100,100)
velocity = Vector2(0,0)
# Add the gravity
if Input.is_action_pressed('down'):
velocity += Vector2(0,SPEED)
if Input.is_action_pressed('up'):
velocity += Vector2(0,0-SPEED)
if Input.is_action_pressed('left'):
velocity += Vector2(0-SPEED,0)
if Input.is_action_pressed('right'):
velocity += Vector2(SPEED,0)
velocity = velocity-(velocity*friction)
var collsion = move_and_collide(velocity*delta)
if collsion:
velocity = velocity.bounce(collsion.get_normal())
move_and_slide()
link to debug project