Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | lavaduder | |
Old Version | Published before Godot 3 was released. |
I didn’t like the floatiness of velocity controls, so I made a control system with set_pos(). And it controls much better. However I have ran into a issue. the set_pos() function overrides collision. So I can move my character smoothly, smoothly through walls. How do make the set_pos() not override the collision of my scene.
#Get position
var charx= get_pos().x setget setcharx
var chary= get_pos().y setget setchary
func _ready():
set_fixed_process(true)
pass
func _fixed_process(delta):
#control variables
var moveu = Input.is_action_pressed("ui_up")
var moved = Input.is_action_pressed("ui_down")
var mover = Input.is_action_pressed("ui_right")
var movel = Input.is_action_pressed("ui_left")
var controlenabled = true
#input
if controlenabled == true:
if (moveu):
setchary(-5)
pass
if (moved):
setchary(5)
pass
if (mover):
setcharx(5)
pass
if (movel):
setcharx(-5)
pass
pass
set_pos(Vector2(charx,chary))
pass
func setcharx(value):
charx = value + get_pos().x
pass
func setchary(value):
chary = value + get_pos().y
pass