Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends CharacterBody2D
- var ballIsActive = false
- var SPEED = 4000.0
- var direction
- # Get the gravity from the project settings to be synced with RigidBody nodes.
- var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
- func _physics_process(delta):
- var collision = move_and_collide(velocity * delta)
- if ballIsActive == false:
- direction = (get_global_mouse_position() - self.global_position).normalized()
- if collision:
- velocity = velocity.bounce(collision.get_normal())
- if Input.is_action_just_pressed("ui_accept"):
- if ballIsActive:
- pass
- else:
- velocity = SPEED * 5 * delta * direction
- ballIsActive = true
- move_and_collide(velocity * delta)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement