0 votes

As the title mentioned, why is this happening? My codes are as below:

Arrow code:

func _physics_process(delta):
if velocity.y < max_shoot_down_speed:
    velocity.y += Global.GRAVITY * mass * delta
var collision = move_and_collide(velocity*delta)
if collision:
    _on_hitting_target(collision)
rotation = velocity.angle()

func _on_hitting_target(collision):
set_physics_process(false)
if collision.collider.is_in_group("Stickable"):
            velocity = Vector2.ZERO
    var target_node = collision.collider
    var temp_position = global_position
    var temp_rotation = global_rotation_degrees
    get_parent().remove_child(self)
    target_node.add_child(self)
    self.global_position = temp_position
    self.global_rotation_degrees = temp_rotation

My enemy moving code is as below:

velocity.y += Global.GRAVITY*delta
move_and_slide(velocity,Vector2(0,-1))

My expectation will be after collision, my enemy still moving constantly with his velocity, but moveandslide() always return me a velocity that seems like affect by the arrow i attached to it.

Anyone please help.

in Engine by (71 points)

Please log in or register to answer this question.

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.