viewing paste jumper | Python

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
extends Area2D
 
var velocity = Vector2(100, 0);
var jump_speed = 1000;
var target = null;
 
func _unhandled_input(event):
    if target and event is InputEventScreenTouch and event.is_pressed:
        jump();
 
func jump():
    target = null;  # Leave taget
    velocity = transform.x * jump_speed;
 
func _on_Jumper_area_entered(area):
    target = area;  # Jumper hit the circle
    velocity = Vector2();   # Stop  moving forward
 
func _physics_process(delta):
    if target:
        transform = target.orbit_position.global_transform;
    else:
        position += velocity * delta;
 
Viewed 418 times, submitted by Guest.