Jump to content


Photo

Why am I getting this error?


  • Please log in to reply
5 replies to this topic

#1 Vilvake

Vilvake

    GMC Member

  • New Member
  • 24 posts

Posted 09 November 2011 - 07:06 AM

Hello everyone, I'm a beginner at gamemaker and am working on a tower defense type game.

My problem is when I kill about 10 spiders, I get this error:

___________________________________________
ERROR in
action number 1
of  Step Event
for object obj_turret2:

Error in code at line 3:
   direction = point_direction(x,y,object.x,object.y);
                                          ^
at position 41: Unknown variable x

Can someone look over my code and tell me what my problem is?

My game

I'm sure it's pretty simple...
  • 0

#2 filulilus

filulilus

    GMC Member

  • GMC Member
  • 928 posts
  • Version:GM:Studio

Posted 09 November 2011 - 07:14 AM

is the variable "object" allways set to an instance?

Edited by filulilus, 09 November 2011 - 07:15 AM.

  • 0

#3 zehevi

zehevi

    GMC Member

  • GMC Member
  • 637 posts
  • Version:GM8

Posted 09 November 2011 - 07:14 AM

This error means that game maker could not find the variable x, probably because he cant find the object "object".
replace with this:
if instance_exists(object) direction = point_direction(x,y,object.x,object.y);

  • 0

#4 Vilvake

Vilvake

    GMC Member

  • New Member
  • 24 posts

Posted 09 November 2011 - 07:31 AM

This error means that game maker could not find the variable x, probably because he cant find the object "object".
replace with this:

if instance_exists(object) direction = point_direction(x,y,object.x,object.y);


thanks, that fixed my problem. I have one more question though,

I want it so if I kill 10 spiders, the spider boss will appear. So I used variables and added 1 to global.level1 ever time I killed a spider.

this is my code to make the spider boss appear..

if global.level1 = 10{
    instance_create(x,y,spider_boss)
}

My question is, how do I create only one spider boss? not many?
  • 0

#5 borut

borut

    Courage Wolf Productions

  • GMC Member
  • 1152 posts
  • Version:GM:Studio

Posted 09 November 2011 - 08:02 AM


if(global.level=10) and instance_count(spider_boss) <= 1{

instance_create(x,y,spider_boss);

}

  • 0

#6 Vilvake

Vilvake

    GMC Member

  • New Member
  • 24 posts

Posted 09 November 2011 - 09:38 AM

if(global.level=10) and instance_count(spider_boss) <= 1{
instance_create(x,y,spider_boss);
}


thanks. I changed instance_count to instance_number and it worked perfectly!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users