Jump to content


StingDaFling

Member Since 20 Jul 2009
Offline Last Active Dec 01 2010 03:33 PM

Posts I've Made

In Topic: Instance identification problem

22 October 2010 - 11:06 PM

inst[n].id
I believe that is your problem. 'inst[n]' should return the id already, no need to add the '.id' after that.
If it doesnt work try adding parenthesis around it:

(inst[0]).image_speed = 0;
Maybe the array is messing around with the return of the id.. my vague guess.. things like that tend to happen with GM.


Oh, and to destroy i guess it is the same problem. One thing trough, remove the 'do' since its pointless:
with (inst[0])
 {
  instance_destroy();
 }


I took out all of the ".id" parts of every code: it does the same thing at before, but it doesn't fix the problem.

(A few minutes later) What the-
I can't believe how stupid I was. I assigned inst[0] to two different objects, and the objects exist at the same time, so it's totally my fault. Looking in the Left Pressed event, I found this code:

inst[0] = instance_create(0,0,spawner1)

I'm so stupid... thanks for your help, anyways. I got both circles to die, and I learned that I don't have to use ".id".

In Topic: Need Someone 2 Explain Enemy A.i.

23 July 2009 - 02:07 AM

Maybe an example of coding would help.

et2002 had some really good stuff, so I'm going to give you an example of each of the things he used and explain them.

Just like he said, "point_distance" helps you be able to have someone chase someone else when approached. But how is this done? Simple, just study this code.

In the "Step" event, this code goes there:
[codebox]if (point_distance(Man.x,Man.y,x,y)<64)
{
  follow=1
}
else
{
  exit
}

if follow=1
{
  // This part will be hard. I'll explain along the way.
  if (x<Man.x)
  {
    direction = 0
    speed = 5
    // OR, you can have this:
    hspeed = 5
  }
  if (x>Man.x)
  {
    direction = 180
    speed = 5
    // You can also do this:
    direction = 0
    speed = -5
    // and THEN you can do this:
    hspeed = -5
  }
}
  // Ok, this is what I just said. If the enemy's x is smaller than Man's x, the enemy will go right,
  // and if the enemy's x is larger than the Man's x, it'll go right.
  // That's good for having him follow on a flat terrain, but if there are jumps then I may explain it later.
  // I myself need to practice that more.[/codebox]

Remember, this would be in the Step event of the enemy's object. Also, there possibly might have to be an action in the Create event stating that the variable "follow" is set to 1.

-SDF  :)