I
Ionn Blignault
Guest
Hey guys,
I'm just getting into GML so I hope this makes sense ha ha...here goes
Ok so I'm playing around with a Space farming concept and I want to implement a radar system that points to objects in the room.
Below you can see the Space Station's marker(red) pointing in it's direction correctly, since there is only one instance of the object i can hard code the point_direction BUT I can't do that for the asteroids and that is what this post is about:
First I loop through all the asteroid objects and push their id's into a global array
for ( i = 0; i < instance_number(obj_asteroid); i += 1 ){
global.asteroid_ids = instance_find( obj_asteroid, i );
}
Then I get the array count to do an instance_create loop for each asteroid
var asteroid_array_count = array_length_1d( global.asteroid_ids );
for( i = 0; i < asteroid_array_count; i++ ){
/* ====
testing to see if x and y values are returned...they are!
show_debug_message(string(i) + " asteroid x: " + string(global.asteroid_ids.x ) );
show_debug_message(string(i) + " asteroid y: " + string(global.asteroid_ids.y ) );
=====*/
//create asteroid marker
var radar_arrow_id = instance_create(obj_player.x, obj_player.y, obj_radar_arrow);
with(radar_arrow_id)
{
?????????
point_direction( obj_player.x, obj_player.y, global.asteroid_ids.x, global.asteroid_ids.y );
}
}
I don't want to use instance_nearest because the markers must have a set target and only that target.
Again, I'm new to GM and GML...actually game development in general LOL so feel free to correct me.
Cheers guys
I'm just getting into GML so I hope this makes sense ha ha...here goes
Ok so I'm playing around with a Space farming concept and I want to implement a radar system that points to objects in the room.
Below you can see the Space Station's marker(red) pointing in it's direction correctly, since there is only one instance of the object i can hard code the point_direction BUT I can't do that for the asteroids and that is what this post is about:
First I loop through all the asteroid objects and push their id's into a global array
for ( i = 0; i < instance_number(obj_asteroid); i += 1 ){
global.asteroid_ids = instance_find( obj_asteroid, i );
}
Then I get the array count to do an instance_create loop for each asteroid
var asteroid_array_count = array_length_1d( global.asteroid_ids );
for( i = 0; i < asteroid_array_count; i++ ){
/* ====
testing to see if x and y values are returned...they are!
show_debug_message(string(i) + " asteroid x: " + string(global.asteroid_ids.x ) );
show_debug_message(string(i) + " asteroid y: " + string(global.asteroid_ids.y ) );
=====*/
//create asteroid marker
var radar_arrow_id = instance_create(obj_player.x, obj_player.y, obj_radar_arrow);
with(radar_arrow_id)
{
?????????
point_direction( obj_player.x, obj_player.y, global.asteroid_ids.x, global.asteroid_ids.y );
}
}
I don't want to use instance_nearest because the markers must have a set target and only that target.
Again, I'm new to GM and GML...actually game development in general LOL so feel free to correct me.
Cheers guys