Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | rodell2020 |
In Godot 3.4.4
1 extends KinematicBody2D
2
3 var velocity = Vector2(0, 0)
4
5 func _physics_process(delta):
6 if Input.is_action_pressed(“ui_right”):
7 velocity.x = 100
8 if Input.is_action_pressed(“ui-letf”):
9 velocity.x = -100
10
11 move_and_slide(velocity)
works push the right arrow and it moves right
push the left arrow it moves left
in Godot 4.0 (any alpha)
it gives us a bunch of errors
Even worst is we do not even have a KinematicBody2D
so when in line 3 var velocity = Vector2(0, 0) it gives me this error
Error at(3,1): Member “velocity” redefined (Original in native class ‘characterBody2D’)
so fine if I type var ve = Vector2(0, 0)
I get rid of that error
but in line 11 move_and_slide(velocity) gives me this error
Error at (11,20): Too many arguments for move_and_slide()" call. Expected at most 0 but received 1
I just tried
var ve = Vector2(0, 0)
func _physics_process(delta):
if Input.is_action_pressed(“ui_right”):
ve.x = 100
if Input.is_action_pressed(“ui_left”):
ve.x = -100
move_and_slide()
it did not give me any errors but nothing happens when i press the right arrow or the left arrow keys. i check Project /Project Settings/Input map
both ui_right and ui_left is listed so what the is trouble
if it works in 3.4.4 why can it not work in 4.0
with Got 4.0 how about meeting us half way by allowing to use code that we took weeks
to create Godot 3.4.4 (or at the very lest try this)
Godot 4.0 create a command that allows to use the new code or the old code
(call the command version (or any thing close to it)
then say
if version = 3.4.4 switch back to the Godot 3.4…4 and run this code then switch to Godot 4.0