Jump to content


Photo

other object with the same parent


  • Please log in to reply
4 replies to this topic

#1 Sprocket Games

Sprocket Games

    GMC Member

  • GMC Member
  • 433 posts
  • Version:GM8

Posted 15 April 2012 - 10:13 PM

if on>0 {
nearest=instance_nearest(x,y,combatants )
mp_potential_settings(100,100,400,true)
mp_potential_step_object(nearest.x,nearest.y,1,Wallp & ammocrate)
image_angle=direction
USPc.x=x
USPc.y=y
USPc.uspp=instance_id
USPc.direction=direction
}
else
exit
Basicly, I need the nearest instance to be the offspring of 'combatants', but not be the object calling the event as it is an offspring of 'combatants' This is for a Free For All match and this is the code for the step event for one of the AIs.
Is there any code or variable like: other_offspring ?
I have tried different things but cannot get them to work. Any ideas how I could fix this?

Edited by Sprocket Games, 15 April 2012 - 10:17 PM.

  • 0

#2 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9260 posts
  • Version:Unknown

Posted 15 April 2012 - 10:21 PM

The easiest way is to simply deactivate the calling instance before finding the nearest instance, then reactivate it after.

if on>0 {
  instance_deactivate_object(id);
  nearest=instance_nearest(x,y,combatants )
  instance_activate_object(id);
  mp_potential_settings(100,100,400,true)
  mp_potential_step_object(nearest.x,nearest.y,1,Wallp & ammocrate)
  image_angle=direction
  USPc.x=x
  USPc.y=y
  USPc.uspp=instance_id
  USPc.direction=direction
}
else
  exit

And I think, since the solution is a mere 2 lines of built-in code, that this is more an Intermediate question, so I'll move it there.

-IMP
  • 0

#3 Sprocket Games

Sprocket Games

    GMC Member

  • GMC Member
  • 433 posts
  • Version:GM8

Posted 15 April 2012 - 10:25 PM

ok, but wouldn't that cause the instance to disappear? And how would it reactivate itself?
  • 0

#4 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9260 posts
  • Version:Unknown

Posted 15 April 2012 - 10:31 PM

When you deactivate an instance, the rest of the code in the current event is still executed before it disappears. By the time the code finishes, it's reactivated again.

Basically, unless you put an "exit" or "break" somewhere in a snippet of code, once the code snippet starts it will always finish. For example, if you put a game_end() in a piece of code, whatever comes after it will still execute before the game actually quits.

-IMP
  • 0

#5 Sprocket Games

Sprocket Games

    GMC Member

  • GMC Member
  • 433 posts
  • Version:GM8

Posted 15 April 2012 - 10:47 PM

Ok. Thanks. Ill report back the result
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users