This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

i have been trying to figured out how to adapt from the movement tutorials about "player move to mouse" movement into some sort of " dash into mouse " that also has the gimmick where its like "the longer you hold, the further you go" kinda like a golf if that sounds right.

However, the movement mechanic just doesnt move the player in any way. is there anything that i forget to do or i didnt notice, thankyou.

extends KinematicBody2D
onready var power = 1
onready var maxpower = 100
onready var powerexcalator = 0.5
var velocity = Vector2()

var aim_direction = global_position.direction_to(get_global_mouse_position())

func _input(event):
    if event.is_action_pressed("click"):
        power = clamp(power+powerexcalator, 0, maxpower)
    elif event.is_action_released("click"):
        velocity = aim_direction*power
        power = 1

# warning-ignore:unused_argument
func _physics_process(delta):
    velocity = move_and_slide(velocity)
in Engine by (19 points)

1 Answer

0 votes

that's not how move_and_slide works.

I would put all your code in the _physics_process event and just check

if Input.is_action_pressed("click"):  power = clamp(power+powerexcalator, 0, maxpower)
if Input.is_action_just_released("click"): 
 velocity = aim_direction*power
 power = 1

by (1,346 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.