Godot Version
4.3
Code
extends CharacterBody2D
heres my code (errors below)
const SPEED = 250.0
const JUMP_VELOCITY = -250.0
const PUSH = 5
const FLOOR_NORMAL=Vector2.UP
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity.y += gravity * delta
#velocity=move_and_slide(velocity,FLOOR_NORMAL)
velocity=move_and_slide(velocity,FLOOR_NORMAL,false,4, 0.785398)
# 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.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
for i in get_slide_collision_count():
var collision=get_slide_collision(i)
if collision.collider is MoveableBlock:
collision.collider.apply_central_impulse(-collision.normal * PUSH)
im getting an error on line 17 “velocity=move_and_slide(velocity,FLOOR_NORMAL,false,4, 0.785398)”
saying “Line 17:Too many arguments for “move_and_slide()” call. Expected at most 0 but received 5.
Line 17:Value of type “bool” cannot be assigned to a variable of type “Vector2”.”