Launching and calling back an object

T

tiberionx

Guest
Hello again friendly people! :D



so im trying to do that r-type thing where you can launch an object and call it back
GML:
// Create
launch_ = false;
stick_ = true;

distance_x = 50;
distance_y = 0;
sticky_ = .05;

//Step
var launcher = keyboard_check_pressed(ord("H"));

if stick_ == true {
x = o_ship.x+48;
y = o_ship.y;
} if stick_ == false  {
x = lerp(x,   o_ship.x + distance_x, sticky_);
y = lerp(y,   o_ship.y + distance_y, sticky_);
}

if launcher && launch_ == false {
    launch_ = true
    alarm[0] = 1;   
    distance_x = 1000
} if launcher && stick_ == false {
    stick_ = true;
    alarm[1] = 1;
    distance_x = 48;
}
// Alarm [0]
move_towards_point(distance_x, y, 10)
launch_ = true;
stick_ = false;
distance_x = 500

// alarm [1]
move_towards_point(distance_x, y, 2)

launch_ = false;
so i can launch the object to the right properly no problems , but when i call it back it just pops in front of the player instantly
 
T

tiberionx

Guest
oh yeah.... thats right , that should be in a variable... or another statement

thanks man !
 
Last edited by a moderator:
T

tiberionx

Guest
errrr .... can someone help me with this , I cant seem to figure it out

Thanks
 
T

tiberionx

Guest
okaaayyy ...
GML:
var launcher = keyboard_check_pressed(ord("H"));

if stick_ == true && latched_ == true {
    x = o_ship.x+48;
    y = o_ship.y;
}
if stick_ == true && (point_distance(x,y, o_ship.x, o_ship.y) > 50) {
    x = lerp(x,   o_ship.x+48, sticky_x);
    y = lerp(y,   o_ship.y, sticky_y);
}

if launcher && launch_ == false {
    alarm[0] = 1
    stick_ = false;
    distance_x = 500;   
    sticky_x = .01;
    latched_ = false;
} if launcher {
    if stick_ == false {
      move_towards_point(o_ship.x+48, y, 1)
    }   
    stick_ = true;
    distance_x = 48;
} if (point_distance(x,y, o_ship.x, o_ship.y) < 32){
    latched_ = true;
    sticky_x = .1;
}
This works a bit better now ,

my problem now is that move_towards_point doesnt follow the speed

and i also have speed = 1 on create
 
T

tiberionx

Guest
What does this mean?

I suspect that most of your problems are because you don't know how to use else. You should learn to use else.
Sorry , i mean i set the speed to 1 but its still moving really fast when moving to point
 
Top