Hi all,
I have been trying to make this work all day. Seems simple but I'm new to game development (but not new to coding).
I got a location of the mouse click against a StaticBody (Ground) and that's working perfectly fine. Moving and rotating works for the first click only but subsequent click become worse and worse. 2nd click sometimes work.
My project is at https://github.com/sidbc/3DCharacterClickToMove
The particular code of the 'Player' attached below. Also a gif animation showing how it currently runs (white ball is showing the mouse click location) and how the first click works but not subsequent clicks: https://github.com/sidbc/3DCharacterClickToMove/blob/master/screencast_problem_1.gif
func _physics_process(delta):
if moving == false:
speed = 0
return
speed += acceleration * delta
if speed > maxspeed:
speed = maxspeed
var transform_origin = transform.origin
var distance_to = transform_origin.distance_to(destination)
# Magic number 5, I don't know why but smaller number doesn't work???
if distance_to > 5:
move_and_slide(destination)
else:
moving = false
func _on_Ground_input_event(camera, event, new_position, normal, shape_idx):
if moving == false and event.is_action_pressed("ui_click"):
moving = true
destination = new_position
elif moving == true and event.is_action_pressed("ui_click"):
moving = false
Please help this newbie! :__(