Godot Version
4.2
Question
Hi everybody, i’m a beginner to Godot, so if i’m saying something stupid, please correct me.
I was playing with the 2D Physics, so i tried to build a simple top-down charachter and some cubes that can be moved around. Being top-down, i decided to use RigidBody2D both for the charachter and for the cubes.
I implement a WASD movement that applies a movement to the charachter (i’ve played around with both forces and impulses.
Now, while it does work, I have two problem:
- Everything fells slippery: the square that is hit never stops, so it seems like there isn’t any friction with the ground. How to set a “global” friction (not for collision with other RigidBodies, but always applied)?
- Hard to turn around: the players is really hard to move around as when he is fast it takes lots of time to “change” direction; i think that this problem is connect to the first one, but if it isn’t, please tell me.
This is my code:
func _input(_ev):
if Input.is_key_pressed(KEY_W):
var player_rigidbody = get_node("PlayerRB2D")
player_rigidbody.apply_central_impulse(Vector2(0.0, -3000.0))
if Input.is_key_pressed(KEY_A):
var player_rigidbody = get_node("PlayerRB2D")
player_rigidbody.apply_central_impulse(Vector2(-3000.0, 0))
if Input.is_key_pressed(KEY_S):
var player_rigidbody = get_node("PlayerRB2D")
player_rigidbody.apply_central_impulse(Vector2(0.0, 3000.0))
if Input.is_key_pressed(KEY_D):
var player_rigidbody = get_node("PlayerRB2D")
player_rigidbody.apply_central_impulse(Vector2(3000.0, 0.0))
Thanks in advance to everybody.