Hey need help with my online topdown shooter, what happens is in the step event of the player object it checks for turrets within a certain range and sees whether that turret has the same id as the player if not then the turret shoots at the player, the problem is it only works for the turret that's closest to the player(you can place 2 turrets hence problem). This is my code and what i attempted to do to fix it but obviously it only works if your on the right of a turret that has another turret to the left of it within 64 pixels.
near=instance_nearest(x,y,obj_turret)
if instance_exists(near)
{
near2=instance_nearest(near.x-64,near.y,obj_turret)
}
if distance_to_object(near) < 320
{
if near.owner_id!=mplay_player_id(0)
{
////code
}}
if instance_exists(near)
{
if distance_to_object(near2) < 320
{
if near2.owner_id!=mplay_player_id(0)
{
////code
}}}So in other words; i want it so two turrets that weren't created by the player and are in range can shoot at the player at the same time (also i don't want to have to create a second turret object or put that code into the turret object.)
Edited by Awesomeman, 09 November 2011 - 08:21 AM.











