Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | onurbulut |
I have a player RigidBody2D.I want to control it with keyboard like GTA2 character.I tried add_force() when press a key.It didnt work.It moves but when i press Left key it moves wrongfully.It should move forward when i press ‘W’ key,but when i press ‘D’ key it should turn slowly left.
My input function
func _input(event):
if Input.is_action_pressed("ui_left"):
add_force(Vector2(0,0),Vector2(-20, 0))
elif Input.is_action_pressed("ui_right"):
add_force(Vector2(0,0),Vector2(20, 0))
elif Input.is_action_pressed("ui_up"):
add_force(Vector2(0,0),Vector2(0,20))
elif Input.is_action_pressed("ui_down"):
add_force(Vector2(0,0),Vector2(0,-20))
else:
applied_force=Vector2(0,0)
I tried to change Mode of RigidBody2D to Kinematic.It doesnt move.The mode is Character.How i imlement GTA 2 style movement in Godot?
Thank you.
I couldnt add image to question.Link:Connexion | Photobox
onurbulut | 2018-10-02 21:34